本地部署语音转文字(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.效果

相关推荐
localbob10 天前
日语视频 SRT 字幕生成软件下载:日语视频本地自动翻译SRT字幕生成、日语视频自动翻译 Faster Whisper v1.7 下载与使用教程(含AMD显卡支持)
whisper·音视频·机器翻译·日语字幕翻译·日语视频翻译·本地ai翻译日语视频
挂科边缘10 天前
手把手教你使用 Faster-Whisper 实时语音输入转文本,本地部署教程
人工智能·语言模型·whisper·faster-whisper·实时语音输入转文本
三千军10 天前
Buzz语音转文字离线免费版安装使用(含Whisper最新模型)
whisper·免费·语音转文字·离线·buzz
SUNNY_SHUN10 天前
把 Whisper、Moonshine、SenseVoice 统统装进手机:sherpa-onnx 离线语音部署框架,GitHub 10.9K Star
人工智能·智能手机·whisper·github
searchforAI10 天前
培训视频转文字后怎么做团队复盘?把本地视频整理成AI笔记的实操方案
人工智能·笔记·ai·whisper·音视频·语音识别·腾讯会议
Wenzar_12 天前
VITS+Whisper微调:低延迟TTS实战
java·人工智能·whisper
PersistJiao13 天前
faster-whisper 字幕识别模型base/medium/large-v3-turbo
whisper
searchforAI13 天前
2026年AI笔记工具对比实测:NotebookLM、通义听悟、Ai好记怎么选?
人工智能·笔记·gpt·ai·whisper·音视频·语音识别
PersistJiao13 天前
Faster-Whisper
whisper
PersistJiao13 天前
针对 Intel Mac 的硬件限制提升faster-whisper字幕识别的方法
macos·whisper