如何在语音识别录音中设置计时器?

2024-06-28 20:47:52 发布

您现在位置:Python中文网/ 问答频道 /正文

我正在windows上编写一个python代码来自动调用一些数字,并指出哪些数字在音频中有错误消息。它称之为使用谷歌Chrome上的网站。问题是:我需要它来听输出音频,而不是输入。你知道吗

我需要我的自动化来听音频和视频 1-说出哪些是沉默的 2-告诉哪些有错误信息

我试着使用一个叫做“cbaudio”的程序,它通过我的输入读取我的输出音频。问题是一旦我这么做了,我的程序就开始无限期地收听音频。因此,我需要要么放一个计时器(我还没有发现是怎么做的),要么直接从googlechrome中录制音频并保存一个我可以使用的音频文件。你知道吗

用Python做的。这不是完整的代码,只是我使用SpeechRecognition的部分

   python
    from selenium import webdriver
    from selenium.webdriver.common.keys import Keys
    from selenium.webdriver import Chrome
    import speech_recognition as sr
    import pyaudio
                    r = sr.Recognizer()
                    with sr.Microphone() as source:
                        audio = r.listen(source)
                        try:
                            stt = r.recognize_google(audio)
                            anet = format(stt)
                            print(anet)
                            ##The lines below are just for finding a word in the audio##
                            if anet.find('america')!= -1 and anet.find('amarica') != -1:
                                for j in range(5):
                                    notWorking.cell(row=sheetY, column=j).value = sheet.cell(row=countY,column=j)
                                sheetY = sheetY + 1
                                nwText.append(clientPhone)
                                nwText.append("\n")
                        except:
                            print("Couldn't understand what you said, or the audio is silent")
                            for j in range(5):
                                notWorking.cell(row=sheetY, column=j).value = sheet.cell(row=countY, column=j)
                            sheetY = sheetY + 1
                            nwText.append(clientPhone)
                            nwText.append("\n")
                    #time.sleep(30)
                    driver.close()

driver.close()命令永远不会发生,它会无限期地收听音频。请问,有人知道我如何在监听命令上设置计时器和/或让它直接监听我的Google Chrome吗?你知道吗


Tags: fromimportseleniumcellcolumnchrome音频audio