-5
我正在考虑为我的学术项目实现文本编辑器,该文本编辑器可以将语音转换为文本并发言。文本编辑器可以将语音转换为文本,反之亦然
是否有可能在Python中进行编码?或者可能呢?如果可能的话,如何?
任何帮助表示赞赏。
我正在考虑为我的学术项目实现文本编辑器,该文本编辑器可以将语音转换为文本并发言。文本编辑器可以将语音转换为文本,反之亦然
是否有可能在Python中进行编码?或者可能呢?如果可能的话,如何?
任何帮助表示赞赏。
是的,这是非常可能的。如果你是初学者,我建议你使用python来做到这一点。您可以将PyQt用于您的GUI,pyttsx和SpeechRecognition用于语音引擎(离线)。执行以下操作来安装:
pip install SpeechRecognition
pip install pyttsx
下面是一些代码,让你在python开始语音识别
import speech_recognition
import pyttsx
speech_engine = pyttsx.init('sapi5') # see http://pyttsx.readthedocs.org/en/latest/engine.html#pyttsx.init
speech_engine.setProperty('rate', 150)
def speak(text):
speech_engine.say(text)
speech_engine.runAndWait()
recognizer = speech_recognition.Recognizer()
def listen():
with speech_recognition.Microphone() as source:
recognizer.adjust_for_ambient_noise(source)
audio = recognizer.listen(source)
try:
return recognizer.recognize_sphinx(audio)
# or: return recognizer.recognize_google(audio)
except speech_recognition.UnknownValueError:
print("Could not understand audio")
except speech_recognition.RequestError as e:
print("Recog Error; {0}".format(e))
return ""
speak("Say something!")
speak("I heard you say " + listen())
让我知道你是否需要任何帮助。如果我的回答对你有帮助,请接受答案。谢谢! –
请花一些时间来阅读帮助页面,特别是命名的章节[“什么我可以问这些话题?“](http://stackoverflow.com/help/on-topic)和[”我应该避免问什么类型的问题?“](http://stackoverflow.com/help/dont -问)。更重要的是,请阅读[Stack Overflow问题清单](http://meta.stackexchange.com/q/156810/204922)。您可能还想了解[最小,完整和可验证示例](http://stackoverflow.com/help/mcve)。 – hering
谢谢你的建议hering。这是我的第一个问题,我真的需要帮助。 –