国产 无码 综合区,色欲AV无码国产永久播放,无码天堂亚洲国产AV,国产日韩欧美女同一区二区

whisperX 語音識別本地部署

這篇具有很好參考價值的文章主要介紹了whisperX 語音識別本地部署。希望對大家有所幫助。如果存在錯誤或未考慮完全的地方,請大家不吝賜教,您也可以點(diǎn)擊"舉報違法"按鈕提交疑問。

WhisperX 是一個優(yōu)秀的開源Python語音識別庫。
下面記錄Windows10系統(tǒng)下部署Whisper
1、在操作系統(tǒng)中安裝 Python環(huán)境
2、安裝 CUDA環(huán)境
3、安裝Annaconda或Minconda環(huán)境
4、下載安裝ffmpeg
下載release-builds包,如下圖所示
whisperX 語音識別本地部署,語音識別,python,人工智能
將下載的包解壓到你想要的路徑,然后配置系統(tǒng)環(huán)境:我的電腦->高級系統(tǒng)設(shè)置->環(huán)境變量->Path
whisperX 語音識別本地部署,語音識別,python,人工智能
whisperX 語音識別本地部署,語音識別,python,人工智能
設(shè)置完成后打開cmd窗口輸入

ffmpeg

whisperX 語音識別本地部署,語音識別,python,人工智能
5、conda環(huán)境安裝指定位置的虛擬環(huán)境

conda create --prefix=D:\Projects\LiimouDemo\WhisperX\Code\whisperX\whisperXVenv python=3.10

6、激活虛擬環(huán)境

conda activate D:\Projects\LiimouDemo\WhisperX\Code\whisperX\whisperXVenv

7、安裝WhisperX庫

pip install git+https://github.com/m-bain/whisperx.git

8、更新WhisperX庫

pip install git+https://github.com/m-bain/whisperx.git --upgrade

9、在Python中使用

import whisperx
import time
import zhconv
device = "cuda"
audio_file = "data/test.mp3"
batch_size = 16 # reduce if low on GPU mem
compute_type = "float16" # change to "int8" if low on GPU mem (may reduce accuracy)
# compute_type = "int8" # change to "int8" if low on GPU mem (may reduce accuracy)
print('開始加載模型')
start = time.time()
# 1. Transcribe with original whisper (batched)
model = whisperx.load_model("large-v2", device, compute_type=compute_type)
# model = whisperx.load_model("small", device, compute_type=compute_type)
end = time.time()
print('加載使用的時間:',end-start,'s')
start = time.time()
audio = whisperx.load_audio(audio_file)
result = model.transcribe(audio, batch_size=batch_size)

print(result["segments"][0]["text"]) # before alignment
end = time.time()
print('識別使用的時間:',end-start,'s')

封裝上述代碼,初始化時調(diào)用一次loadModel()方法,之后使用就直接調(diào)用asr(path)方法

import whisperx
import zhconv
from whisperx.asr import FasterWhisperPipeline
import time

class WhisperXTool:
    device = "cuda"
    audio_file = "data/test.mp3"
    batch_size = 16  # reduce if low on GPU mem
    compute_type = "float16"  # change to "int8" if low on GPU mem (may reduce accuracy)
    # compute_type = "int8" # change to "int8" if low on GPU mem (may reduce accuracy)
    fast_model: FasterWhisperPipeline

    def loadModel(self):
        # 1. Transcribe with original whisper (batched)
        self.fast_model = whisperx.load_model("large-v2", self.device, compute_type=self.compute_type)
        print("模型加載完成")

    def asr(self, filePath: str):
        start = time.time()
        audio = whisperx.load_audio(filePath)
        result = self.fast_model.transcribe(audio, batch_size=self.batch_size)
        s = result["segments"][0]["text"]
        s1 = zhconv.convert(s, 'zh-cn')
        print(s1)
        end = time.time()
        print('識別使用的時間:', end - start, 's')
        return s1

zhconv是中文簡體繁體轉(zhuǎn)換的庫,安裝命令如下文章來源地址http://www.zghlxwxcb.cn/news/detail-568326.html

pip install zhconv

到了這里,關(guān)于whisperX 語音識別本地部署的文章就介紹完了。如果您還想了解更多內(nèi)容,請?jiān)谟疑辖撬阉鱐OY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!

本文來自互聯(lián)網(wǎng)用戶投稿,該文觀點(diǎn)僅代表作者本人,不代表本站立場。本站僅提供信息存儲空間服務(wù),不擁有所有權(quán),不承擔(dān)相關(guān)法律責(zé)任。如若轉(zhuǎn)載,請注明出處: 如若內(nèi)容造成侵權(quán)/違法違規(guī)/事實(shí)不符,請點(diǎn)擊違法舉報進(jìn)行投訴反饋,一經(jīng)查實(shí),立即刪除!

領(lǐng)支付寶紅包贊助服務(wù)器費(fèi)用

相關(guān)文章

覺得文章有用就打賞一下文章作者

支付寶掃一掃打賞

博客贊助

微信掃一掃打賞

請作者喝杯咖啡吧~博客贊助

支付寶掃一掃領(lǐng)取紅包,優(yōu)惠每天領(lǐng)

二維碼1

領(lǐng)取紅包

二維碼2

領(lǐng)紅包