本地部署语音转文字(whisper,SpeechRecognition)

本地部署语音转文字

1.whisper

1.首先安装Chocolatey

https://github.com/openai/whisper

以管理员身份运行PowerShell

python 复制代码
Set-ExecutionPolicy Bypass -Scope Process -Force; [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072; iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))
choco -v#查看版本确定安装成功
Set-ExecutionPolicy AllSigned
Set-ExecutionPolicy Bypass -Scope Process -Force; [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072; iex ((New-Object System.Net.WebClient).DownloadString('https://community.chocolatey.org/install.ps1'))

2.安装

python 复制代码
choco install ffmpeg
pip install setuptools-rust
pip install -U openai-whisper

3.使用

python 复制代码
whisper 1207.m4a --language Chinese --model medium --device cuda:0 

2.SpeechRecognition

1.环境

python 复制代码
pip install SpeechRecognition
pip install -i https://pypi.tuna.tsinghua.edu.cn/simple pocketsphinx

2.中文包

在这个虚拟环境的\site-packages\speech_recognition\pocketsphinx-data目录下添加zh-CN中文包。

3.格式转化

因为这个离线只支持一下三种格式,所以利用ffmpeg将语音转换成wav格式,这个包在装whisper的时候已经装好了,所以直接用:

python 复制代码
 ffmpeg -i 12072.m4a output.wav
  • 1.WAV
    2.AIFF/AIFF-C
    3.FLAC

4.运行

python 复制代码
import speech_recognition as sr
audio_file = 'output.wav'
r = sr.Recognizer()
with sr.AudioFile(audio_file) as source:
    audio = r.record(source)
# 识别音频文件
result = r.recognize_sphinx(audio, language="zh-CN")
print(result)

3.效果

相关推荐
skywalk816318 小时前
Windows下安装编译安装Whisper-CPP:一个语音实现框架集和高性能推理模型
人工智能·windows·whisper
linux开发之路2 天前
C++实现Whisper+Kimi端到端AI智能语音助手
c++·人工智能·llm·whisper·openai
吱夏cz8 天前
安装whisper
whisper
Jay星晴9 天前
Whisper-large-v3语音识别效果对比:与Whisper v2/v1在中文长语音场景差异
whisper·语音识别·asr·星图gpu
FishPotatoChen11 天前
【OpenAI】Whisper 模型架构详解
whisper
weixin_4462608513 天前
[特殊字符] Insanely Fast Whisper - 超快音频转录工具!
whisper·音视频
x-cmd14 天前
[260326] x-cmd v0.8.10:跨 Shell 统一配置命令短名;自动装好依赖运行 WhisperLiveKit 实时语音转写
linux·人工智能·ai·whisper·shortcut·x-cmd
ughome24 天前
我做了一个本地字幕提取工具:软字幕优先 + Whisper 转写回退(支持链接/本地文件)
whisper·视频字幕提取
PengShuaiD51 个月前
【AI编码】用ChatGPT基于Whisper+ffmpeg实现一个根据视频字幕执行自动化裁剪本地小工具
人工智能·chatgpt·ffmpeg·whisper
susu10830189112 个月前
OpenAI Whisper 把mp3语音转文字
whisper