forked from React-Group/interstellar_ai
Small refactoring
This commit is contained in:
parent
1ec120b933
commit
0ae104a4f0
1 changed files with 12 additions and 12 deletions
|
@ -196,21 +196,21 @@ const InputOutputBackend: React.FC = () => {
|
||||||
ffmpegRef.current = new FFmpeg()
|
ffmpegRef.current = new FFmpeg()
|
||||||
await ffmpegRef.current.load()
|
await ffmpegRef.current.load()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const convertOggToWav = async (oggFile: File | Blob) => {
|
const convertOggToWav = async (oggFile: File | Blob) => {
|
||||||
await loadFFmpeg()
|
await loadFFmpeg()
|
||||||
|
|
||||||
const ffmpeg = ffmpegRef.current!
|
const ffmpeg = ffmpegRef.current!
|
||||||
|
|
||||||
await ffmpeg.writeFile("input.ogg", await fetchFile(oggFile))
|
await ffmpeg.writeFile("input.ogg", await fetchFile(oggFile))
|
||||||
await ffmpeg.exec(["-i", "input.ogg", "output.wav"])
|
await ffmpeg.exec(["-i", "input.ogg", "output.wav"])
|
||||||
const wavData = await ffmpeg.readFile("output.wav")
|
const wavData = await ffmpeg.readFile("output.wav")
|
||||||
console.log(wavData);
|
console.log(wavData);
|
||||||
const wavBlob = new Blob([wavData], { type: "audio/wav" })
|
const wavBlob = new Blob([wavData], { type: "audio/wav" })
|
||||||
audioRef.current = URL.createObjectURL(wavBlob)
|
audioRef.current = URL.createObjectURL(wavBlob)
|
||||||
return wavBlob
|
return wavBlob
|
||||||
}
|
}
|
||||||
|
|
||||||
const stopRecording = () => {
|
const stopRecording = () => {
|
||||||
mediaRecorderRef.current?.stop()
|
mediaRecorderRef.current?.stop()
|
||||||
|
|
Loading…
Reference in a new issue