def main(): """ load the environment variables """ dotenv_path = join(dirname(__file__), '.env') load_dotenv(dotenv_path) """ initialize the speech to text service """ stt = SpeechToText( username=os.environ.get("STT_USERNAME"), password=os.environ.get("STT_PASSWORD")) """ initialize the recorder, provide a filename to save it as """ recorder = Recorder("speech.wav") print("How can I help you?\n") recorder.record_to_file() print("Transcribing audio....\n") result = transcribe_audio(stt, 'speech.wav') text = result['results'][0]['alternatives'][0]['transcript'] print("Text: " + text + "\n")
def main(): dotenv_path = join(dirname(__file__), '.env') load_dotenv(dotenv_path) stt = SpeechToText(username=os.environ.get("STT_USERNAME"), password=os.environ.get("STT_PASSWORD")) recorder = Recorder("speech.wav") print("Please say something into the microphone\n") recorder.record_to_file() print("Transcribing audio....\n") result = transcribe_audio(stt, 'speech.wav') text = result['results'][0]['alternatives'][0]['transcript'] print("Text: " + text + "\n")