本地视频中的SFSpeechRecognizer

发布于 2025-01-27 14:20:52 字数 305 浏览 7 评论 0 原文

我正在尝试从视频中实现语音转录(语音到文本)。我的方法是将其分解为3个步骤:

  1. 将视频文件转换
  2. 为带有音频文件URL
  3. PRASE结果

的SFSpeechRecognizer请求我的问题是,我没有找到一种转换源视频文件的方法(让我们说.mov)进入只有音频文件。视频的Avasset本身没有任何音频轨道,但是在播放文件时仍然具有音频(因此确实存在)。

我想如果我可以解决步骤1,那么2 + 3是微不足道的,所以我的问题是 - 将视频文件转换为仅音频文件的最佳方法是什么,然后我可以将其用于转录。

I'm trying to implement speech transcription (voice to text) from a video. My approach is breaking this down into 3 steps:

  1. Convert video to audio file (m4a/mp3)
  2. Pass audio to SFSpeechRecognizer request with audio file url
  3. Prase results

My issue is that I haven't found a way to convert the source video file (let's say .mov) into an audio only file. The AVAsset itself of the video, doesn't have any audio tracks, but still has audio when playing the file (so it does exist).

I imagine if I can solve step 1, then 2 + 3 are trivial, so my question is - what is the best way to convert a video file into an audio only file, which I can then use for transcription.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

如果没有你 2025-02-03 14:20:52

您可以使用 ffmpegkit 库来提取视频的音频部分。

图书馆示例:

提取音频的ffmpeg命令示例:

You can use FFmpegKit library to extract an audio part of the video.

The library example: https://github.com/tanersener/ffmpeg-kit/tree/main/apple#3-using

The ffmpeg command example to extract audio: https://stackoverflow.com/a/27413824/5707560

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文