2016-11-11 77 views
-5

我正在考慮爲我的學術項目實現文本編輯器,該文本編輯器可以將語音轉換爲文本併發言。文本編輯器可以將語音轉換爲文本,反之亦然

是否有可能在Python中進行編碼?或者可能呢?如果可能的話,如何?

任何幫助表示讚賞。

+0

請花一些時間來閱讀幫助頁面,特別是命名的章節[「什麼我可以問這些話題?「](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

+0

謝謝你的建議hering。這是我的第一個問題,我真的需要幫助。 –

回答

-1

是的,這是非常可能的。如果你是初學者,我建議你使用python來做到這一點。您可以將PyQt用於您的GUI,pyttsxSpeechRecognition用於語音引擎(離線)。執行以下操作來安裝:

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()) 
+0

讓我知道你是否需要任何幫助。如果我的回答對你有幫助,請接受答案。謝謝! –

相關問題