Whisper 通过 mp3输出中文

像剪映和一些软件一样,识别字幕,输出文本,用Whisper。

Whisper是openai推出的,一种开源语音识别模型,能够识别很多种语言,然后将音频转成文字

python实现。


不懂代码的,用图形界面buzzconst-me/whisper


python记住一定要安装3.9 - 3.11 之间,我用到3.9.9


命令是这样:whisper --language Chinese --model large audio.mp3

就可以输出了。


也可以写代码:

代码如下:

py 复制代码
import os.path
import whisper

model = whisper.load_model("turbo")

# load audio and pad/trim it to fit 30 seconds
audio_path = os.path.join(os.path.dirname(__file__), "1.mp3")
audio = whisper.load_audio(audio_path)
audio = whisper.pad_or_trim(audio)

# make log-Mel spectrogram and move to the same device as the model
mel = whisper.log_mel_spectrogram(audio, n_mels=model.dims.n_mels).to(model.device)

# detect the spoken language
_, probs = model.detect_language(mel)
print(f"Detected language: {max(probs, key=probs.get)}") # 检测是哪国语言

# decode the audio
options = whisper.DecodingOptions()
result = whisper.decode(model, mel, options)

# print the recognized text
print(result.text) # 输出结果
相关推荐
你的人类朋友1 天前
【Node】单线程的Node.js为什么可以实现多线程?
前端·后端·node.js
iナナ1 天前
Spring Web MVC入门
java·前端·网络·后端·spring·mvc
CoderYanger1 天前
优选算法-双指针:2.复写零
java·后端·算法·leetcode·职场和发展
数据知道1 天前
Go基础:用Go语言操作MongoDB详解
服务器·开发语言·数据库·后端·mongodb·golang·go语言
大鱼七成饱1 天前
apache POI 万字总结:满足你对报表一切幻想
后端
数据知道1 天前
Go基础:Go语言应用的各种部署
开发语言·后端·golang·go语言
数据知道1 天前
Go基础:用Go语言操作MySQL详解
开发语言·数据库·后端·mysql·golang·go语言
种时光的人1 天前
无状态HTTP的“记忆”方案:Spring Boot中Cookie&Session全栈实战
服务器·spring boot·后端·http
m0_480502641 天前
Rust 登堂 之 Cell 和 RefCell(十二)
开发语言·后端·rust
LunarCod1 天前
Onvif设备端项目框架介绍
后端·嵌入式·c/c++·wsdl·rv1126·onvif