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

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

    正在检查是否收录...

本地部署语音转文字

1.whisper 1.首先安装Chocolatey 2.安装 3.使用 2.SpeechRecognition 1.环境 2.中文包 3.格式转化 4.运行 3.效果

1.whisper

1.首先安装Chocolatey

https://github.com/openai/whisper
以管理员身份运行PowerShell

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.安装

choco install ffmpeg pip install setuptools-rust pip install -U openai-whisper 

3.使用

whisper 1207.m4a --language Chinese --model medium --device cuda:0 

这时会自动下载模型文件到用户的.cache文件夹里面,我的电脑在C:\Users\robot\.cache\whisper

2.SpeechRecognition

1.环境

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的时候已经装好了,所以直接用:

 ffmpeg -i 12072.m4a output.wav 
1.WAV
2.AIFF/AIFF-C
3.FLAC

4.运行

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.效果

codewhisperstemclitpuopenaiwebunitmunshellmediumpowershell本地部署文件夹自动下载模型管理员diygitbot虚拟环境unitygithub语音转换语音转文字url

  • 本文作者:WAP站长网
  • 本文链接: https://wapzz.net/post-5195.html
  • 版权声明:本博客所有文章除特别声明外,均默认采用 CC BY-NC-SA 4.0 许可协议。
本站部分内容来源于网络转载,仅供学习交流使用。如涉及版权问题,请及时联系我们,我们将第一时间处理。
文章很赞!支持一下吧 还没有人为TA充电
为TA充电
还没有人为TA充电
0
  • 支付宝打赏
    支付宝扫一扫
  • 微信打赏
    微信扫一扫
感谢支持
文章很赞!支持一下吧
关于作者
2.7W+
7
0
1
WAP站长官方

【stable diffusion LORA训练】改进lora-scripts,命令行方式训练LORA,支持SDXL训练

上一篇

【AI实战】llama.cpp量化cuBLAS编译;nvcc fatal:Value ‘native‘ is not defined for option ‘gpu-architecture‘

下一篇
  • 复制图片
按住ctrl可打开默认菜单