ishido
ishido

Reputation: 4245

Calling Bing or IBM text-to-speech API in Python?

Is there a way to call the Bing Text To Speech API or the IBM Text To Speech API through Python?

Maybe in the fashion that Python's SpeechRecognition library works?

Upvotes: 2

Views: 3498

Answers (2)

Adarsa Sivaprasad
Adarsa Sivaprasad

Reputation: 51

For Bing translation, set BING_KEY=**your key**.

You could then do translation as bing_en_US=recognizer.recognize_bing(audio, key=BING_KEY, language="en-US").

Ref: https://pypi.python.org/pypi/SpeechRecognition/

Get your key here:https://azure.microsoft.com/en-us/try/cognitive-services/?api=speech-api

Upvotes: 3

Sergei Glimis
Sergei Glimis

Reputation: 478

I believe you can add:

return recognizer.recognize_ibm(audio)

in the code after downloading everything you need including the IBM zip file here:

https://github.com/watson-developer-cloud/speech-to-text-websockets-python

heres the entire code:

import speech_recognition


while 1:
    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) 
                    #return recognizer.recognize_google(audio)
                    return recognizer.recognize_ibm(audio)
            except speech_recognition.UnknownValueError:
                    print("Could not understand audio")
            except speech_recognition.RequestError as e:
                    print("Recog Error; {0}".format(e))

            return ""


    listen()

    print (listen())

Upvotes: 1

Related Questions