【问题标题】:Text editor which can convert speech to text and vice-versa [closed]可以将语音转换为文本的文本编辑器,反之亦然[关闭]
【发布时间】:2017-03-25 18:08:38
【问题描述】:

我正在考虑为我的学术项目实施一个文本编辑器,它可以将语音转换为文本并说出书面文本。

是否可以用 Python 编写代码?或者有可能吗?如果可能,怎么做?

感谢任何帮助。

【问题讨论】:

标签: python windows text-editor


【解决方案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())

【讨论】:

  • 如果您需要更多帮助,请告诉我。如果我的回答对你有帮助,请采纳。谢谢!
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2010-09-12
  • 1970-01-01
  • 2016-09-20
相关资源
最近更新 更多