How to import google cloud speech recognition in Google App Engine (python)

前端 未结 2 1794
被撕碎了的回忆
被撕碎了的回忆 2021-01-15 09:27

I want to use google.cloud library on my Google App Engine python application. In my local all my tests work since I installed this library on my local. I was expecting it t

2条回答
  •  不思量自难忘°
    2021-01-15 09:59

    Try this: sudo pip install --upgrade google-cloud-speech

    Or:

    I'm using another library,
    Does this method help you up?

    import speech_recognition as sp
    import time
    
    print("Say something!")
    
    while True:
        rec = sp.Recognizer()
        with sp.Microphone() as mic:
            audio = rec.listen(mic)
        try:
            print(rec.recognize_google(audio))
        except sp.UnknownValueError:
            print("I cannot understand what you said")
            time.sleep(0.5)
            print("Say again")
        except sp.RequestError as e:
            print("Error".format(e))
        word = rec.recognize_google(audio)
    
        if word == 'goodbye':
            break
    

    Installation:

    sudo pip install SpeechRecognition
    
    sudo pip install pyaudio
    

    If you found an error:

    sudo apt-get install python-pyaudio
    
    sudo apt-get install libjack-jackd2-dev portaudio19-dev
    

    Then again:

    sudo pip install pyaudio
    

    If you found error try this:

    sudo pip install --upgrade pyaudio
    

提交回复
热议问题