您好,登錄后才能下訂單哦!
基于Python PaddleSpeech怎么實(shí)現(xiàn)語(yǔ)音文字處理,針對(duì)這個(gè)問(wèn)題,這篇文章詳細(xì)介紹了相對(duì)應(yīng)的分析和解答,希望可以幫助更多想解決這個(gè)問(wèn)題的小伙伴找到更簡(jiǎn)單易行的方法。
首先我們看一下項(xiàng)目結(jié)構(gòu)以及安裝文檔。
需要Python3.7以上、C++環(huán)境、requirements安裝等等,下面按照我的順序說(shuō)一下。
1、conda安裝Python3.9虛擬環(huán)境
使用conda安裝python3.9環(huán)境,命令如下。
conda create -n py39 python=3.9
2、安裝Visual Studio 2019
安裝地址: Microsoft C++ 生成工具 - Visual Studio
注意安裝的時(shí)候需要勾選C++桌面開(kāi)發(fā)。
3、安裝requirements.txt
使用命令安裝requiremets.txt,命令如下:
pip install -r requirements.txt -i https://pypi.douban.com/simple
這里要注意一下,paddlespeech_ctcdecoders安裝失敗的話無(wú)所謂,可以略掉。
4、安裝paddlepaddle和paddlespeech
命令如下:
pip install paddlepaddle -i https://mirror.baidu.com/pypi/simple pip install paddlespeech -i https://pypi.tuna.tsinghua.edu.cn/simple
5、nltk_data下載
按照項(xiàng)目安裝文檔內(nèi)的說(shuō)明。
我的本地目錄地址如下
我下面分別驗(yàn)證一下tts、asr以及標(biāo)點(diǎn)恢復(fù)功能。
使用命令如下:
paddlespeech tts --input "南京現(xiàn)在很冷,下次再去夫子廟吧。" --output C:\Users\xxx\Desktop\115.wav
執(zhí)行過(guò)程
(dh_partner) D:\spyder\PaddleSpeech>paddlespeech tts --input "南京現(xiàn)在很冷,下次再去夫子廟吧。" --output C:\Users\xxx\Desktop\115.wav phones_dict: None [2022-01-05 17:23:43,642] [ INFO] [log.py] [L57] - File C:\Users\huyi\.paddlespeech\models\fastspeech3_csmsc-zh\fastspeech3_nosil_baker_ckpt_0.4.zip md5 checking... [2022-01-05 17:23:44,742] [ INFO] [log.py] [L57] - Use pretrained model stored in: C:\Users\huyi\.paddlespeech\models\fastspeech3_csmsc-zh\fastspeech3_nosil_baker_ckpt_0.4 self.phones_dict: C:\Users\huyi\.paddlespeech\models\fastspeech3_csmsc-zh\fastspeech3_nosil_baker_ckpt_0.4\phone_id_map.txt [2022-01-05 17:23:44,743] [ INFO] [log.py] [L57] - C:\Users\huyi\.paddlespeech\models\fastspeech3_csmsc-zh\fastspeech3_nosil_baker_ckpt_0.4 [2022-01-05 17:23:44,744] [ INFO] [log.py] [L57] - C:\Users\huyi\.paddlespeech\models\fastspeech3_csmsc-zh\fastspeech3_nosil_baker_ckpt_0.4\default.yaml [2022-01-05 17:23:44,744] [ INFO] [log.py] [L57] - C:\Users\huyi\.paddlespeech\models\fastspeech3_csmsc-zh\fastspeech3_nosil_baker_ckpt_0.4\snapshot_iter_76000.pdz self.phones_dict: C:\Users\huyi\.paddlespeech\models\fastspeech3_csmsc-zh\fastspeech3_nosil_baker_ckpt_0.4\phone_id_map.txt [2022-01-05 17:23:44,745] [ INFO] [log.py] [L57] - File C:\Users\huyi\.paddlespeech\models\pwgan_csmsc-zh\pwg_baker_ckpt_0.4.zip md5 checking... [2022-01-05 17:23:44,782] [ INFO] [log.py] [L57] - Use pretrained model stored in: C:\Users\huyi\.paddlespeech\models\pwgan_csmsc-zh\pwg_baker_ckpt_0.4 [2022-01-05 17:23:44,783] [ INFO] [log.py] [L57] - C:\Users\huyi\.paddlespeech\models\pwgan_csmsc-zh\pwg_baker_ckpt_0.4 [2022-01-05 17:23:44,783] [ INFO] [log.py] [L57] - C:\Users\huyi\.paddlespeech\models\pwgan_csmsc-zh\pwg_baker_ckpt_0.4\pwg_default.yaml [2022-01-05 17:23:44,785] [ INFO] [log.py] [L57] - C:\Users\huyi\.paddlespeech\models\pwgan_csmsc-zh\pwg_baker_ckpt_0.4\pwg_snapshot_iter_400000.pdz vocab_size: 268 frontend done! encoder_type is transformer decoder_type is transformer C:\Users\huyi\.conda\envs\dh_partner\lib\site-packages\paddle\framework\io.py:415: DeprecationWarning: Using or importing the ABCs from 'collections' instead of from 'collections.abc' i s deprecated since Python 3.3, and in 3.10 it will stop working if isinstance(obj, collections.Iterable) and not isinstance(obj, ( acoustic model done! voc done! Building prefix dict from the default dictionary ... [2022-01-05 17:23:51] [DEBUG] [__init__.py:113] Building prefix dict from the default dictionary ... Loading model from cache C:\Users\huyi\AppData\Local\Temp\jieba.cache [2022-01-05 17:23:51] [DEBUG] [__init__.py:132] Loading model from cache C:\Users\huyi\AppData\Local\Temp\jieba.cache Loading model cost 0.659 seconds. [2022-01-05 17:23:52] [DEBUG] [__init__.py:164] Loading model cost 0.659 seconds. Prefix dict has been built successfully. [2022-01-05 17:23:52] [DEBUG] [__init__.py:166] Prefix dict has been built successfully. C:\Users\huyi\.conda\envs\dh_partner\lib\site-packages\paddle\fluid\dygraph\math_op_patch.py:251: UserWarning: The dtype of left and right variables are not the same, left dtype is padd le.int64, but right dtype is paddle.int32, the right dtype will convert to paddle.int64 warnings.warn( [2022-01-05 17:23:58,811] [ INFO] [log.py] [L57] - Wave file has been generated: C:\Users\xxx\Desktop\115.wav
生成的音頻如下
我就使用了tts生成的音頻進(jìn)行asr識(shí)別,看看效果,命令如下:
paddlespeech asr --lang zh --input C:\Users\xxx\Desktop\115.wav
執(zhí)行結(jié)果如下
可以看到最后打印的內(nèi)容是沒(méi)有標(biāo)點(diǎn)的文字輸出,還是比較準(zhǔn)的。
就用這句話試試標(biāo)點(diǎn)恢復(fù)的情況,命令如下:
paddlespeech text --task punc --input 南京現(xiàn)在很冷下次再去夫子廟吧
執(zhí)行結(jié)果
關(guān)于基于Python PaddleSpeech怎么實(shí)現(xiàn)語(yǔ)音文字處理問(wèn)題的解答就分享到這里了,希望以上內(nèi)容可以對(duì)大家有一定的幫助,如果你還有很多疑惑沒(méi)有解開(kāi),可以關(guān)注億速云行業(yè)資訊頻道了解更多相關(guān)知識(shí)。
免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如果涉及侵權(quán)請(qǐng)聯(lián)系站長(zhǎng)郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。