NodeJS:通过 fs.writeFile 和 Blob 创建的每个音频文件都长度过大
我正在创建一个应用程序,需要获取用户的语音并将其转换为文本,但音频文件创建后的长度似乎有问题。
这里是我收集音频并将数据转换为 Blob 的方式。我只是使用 getUserMedia 方法来录制音频并在停止时将其转换为 Blob。
Img 这是查看文件时的样子的图片。
尽管这似乎不是什么大问题,因为收听文件提供了正确的音频,但我将文件传递给将其转换为文本的 API,并且它几乎总是给出错误的翻译或有关包含以下内容的文件的错误:没有什么。我尝试了不同的方法将 Blob 数据写入文件,并尝试切断多余长度的音频,但没有任何效果。
这是我关于堆栈溢出的第一篇文章,因为我没有办法解决这个问题,所以如果问题有点模糊或者我以某种方式错误地格式化了它,我很抱歉。
I'm creating an app which needs to take the user's voice and convert it to text, but the audio file seems to have something wrong with the length after it's creation.
Here is how I'm gathering the audio and converting the data to a Blob. I'm just using the getUserMedia method to record the audio and convert it to a Blob when its stopped.
This is the beginning of the function I pass the Blob object to. I convert the Blob to a buffer and write that buffer to a file in the root directory of my project. But once the file has been written and I go to listen to it, the length of the audio is 435:13:24 no matter how long the original audio was. But even though the length is that long, the file sounds exactly like it should and ends at the correct time.
Img Heres a picture of what the file looks like when viewed.
Although this may not seem like a big deal since listening to the file provides the correct audio, I'm passing the file to an API that converts it to text, and it almost always gives either the wrong translation or an error about the file containing nothing. I've tried different ways of writing the Blob data to the file, and tried cutting off the excess length audio, but nothing has worked.
This is my first post on stack overflow since I ran out of options to fix this, so I'm sorry if the question is kind of vague or I formatted it incorrectly in some way.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论