def test_speech(self): wavfile = os.path.join(os.path.dirname(__file__), "./data/test_speech.wav") text = "welcome to microsoft oxford speech api" api = pyoxford.speech(envs.FILE_PATH) binary = api.text_to_speech(text) with open(wavfile, "wb") as f: f.write(binary) if os.path.isfile(wavfile): recognized = api.speech_to_text(wavfile) self.assertEqual(text, recognized)
def test_speech(self): wavfile = os.path.join(os.path.dirname(__file__), "./data/test_speech.wav") text = "welcome to microsoft speech api" api = pyoxford.speech(envs.FILE_PATH) binary = api.text_to_speech(text) with open(wavfile, "wb") as f: f.write(binary) if os.path.isfile(wavfile): recognized = api.speech_to_text(wavfile) self.assertEqual(text, recognized.lower())
import pyoxford text = "welcome to microsoft oxford speech api" api = pyoxford.speech("your_client_id", "your_client_secret") # text to speech (.wav file) binary = api.text_to_speech(text) with open("voice.wav", "wb") as f: f.write(binary) # speech to text recognized = api.speech_to_text("voice.wav") if text == recognized: print("success!!")
import pyoxford, sys from tokens import * if len(sys.argv) == 2: text = sys.argv[1] api = pyoxford.speech("kage-test-speech", oxford_speech_api) # text to speech (.wav file) binary = api.text_to_speech(text) with open("synthesized.wav", "wb") as f: f.write(binary) # speech to text recognized = api.speech_to_text("synthesized.wav") if text.lower() == recognized.lower(): print("Recognized : " + recognized) print("The recognized string is same as your input string") else: print("Voice is synthesized, however the recognized string is not same as your input string") print("Input String : " + text) print("Recognized : " + recognized) else: print("You should input the test as argument!")
import pyoxford, sys from tokens import * if len(sys.argv) == 2: text = sys.argv[1] api = pyoxford.speech("kage-test-speech", oxford_speech_api) # text to speech (.wav file) binary = api.text_to_speech(text) with open("synthesized.wav", "wb") as f: f.write(binary) # speech to text recognized = api.speech_to_text("synthesized.wav") if text.lower() == recognized.lower(): print("Recognized : " + recognized) print("The recognized string is same as your input string") else: print( "Voice is synthesized, however the recognized string is not same as your input string" ) print("Input String : " + text) print("Recognized : " + recognized) else: print("You should input the test as argument!")