小编Anw*_*eez的帖子

如何让语音识别在听完一个单词后停止收听?

我正在制作一个 PygLatin 口语翻译器。一个非常基本的至少可以告诉一个翻译的单词。

如果我说多个单词,它就会变得混乱,并把第一个单词中的第一个字符放在最后一个单词上,最后加上“ay”。

因此,我遇到了一些问题。有没有办法让它在只说出一个单词后就停止监听?是否有可能有一种方法可以将每个单词的第一个字母放在每个口头单词的末尾,后跟“ay”?

这是到目前为止我的代码示例:

import time
import speech_recognition as sr
from gtts import gTTS
import urllib3
urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)
from pygame import mixer
mixer.init()
pyg = "ay" 
count = 3
while count > 0:
    while (True == True):
  # get audio input
        original = sr.Recognizer()
        with sr.Microphone() as source:
      # listen for 1 second and create the ambient noise energy level
            original.adjust_for_ambient_noise(source, duration = 1)
            print("Say ONE word. If you do not wish to use the translator, say 'stop' ") …
Run Code Online (Sandbox Code Playgroud)

speech-recognition translation speech-to-text python-3.x

6
推荐指数
0
解决办法
1103
查看次数