五千年(敝帚自珍)

主题:OpenAI Whisper 转换声音到文字 -- nanimarcusboy

共:💬12 🌺51 新:
全看分页树展 · 主题 跟帖
家园 利用 Whisper 服务识别,速度是本机的 20 倍

参考

https://platform.openai.com/docs/guides/speech-to-text

----

import openai

audio_file= open("/path/to/file/audio.mp3", "rb")

transcript = openai.Audio.transcribe("whisper-1", audio_file)

----

后一句修改一下,这样拿到的是 srt 文件

transcript = openai.Audio.transcribe("whisper-1", audio_file, ,

response_format="srt")

----

文件大小限制是 25M,所以一般先转换成mp3:

ffmpeg -hide_banner -y -i input.mp4 -acodec libmp3lame -b:a 64k output.mp3

25M mp3 差不多 50 分钟。

再大的话可切成小段,处理后再合并。

----

典型 mp3 文件长度 600秒,识别用了25秒:

-- length : 600.792 seconds

-- runtime: 25.17 seconds

----

好吧,现在看看给了我多少quota.

----

全看分页树展 · 主题 跟帖


有趣有益,互惠互利;开阔视野,博采众长。
虚拟的网络,真实的人。天南地北客,相逢皆朋友

Copyright © cchere 西西河