+
95
-

python如何实现文字转语音声音、声音识别文字?

python如何实现文字转语音声音、声音识别文字?


网友回复

+
15
-

1、python语音识别可以使用speech_recognition

安装pip install speech_recognition

识别代码:

# -*- coding: utf-8 -*-
# /usr/bin/python
import speech_recognition as sr
r = sr.Recognizer()    #调用识别器
test = sr.AudioFile("/data/wwwroot/default/asset/voice.flac")   #导入语音文件
with test as source:       
    audio = r.record(source)
type(audio)
c=r.recognize_sphinx(audio, language='zh-cn')     #识别输出
print(c)

注意:pocketsphinx需要安装的中文语言、声学模型

下载地址:ht...

点击查看剩余70%

+
15
-

还可以使用微软的文字转语音服务,支持140种语言,声音非常接近人声

import asyncio
from msspeech import MSSpeech


async def main():
	mss = MSSpeech()
	print("Geting voices...")
	voices = await mss.get_voices_list()
	print("人工智能是未来")
	for voice in voices:
		if voice["Loca...

点击查看剩余70%

我知道答案,我要回答