Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import json
- import os
- import sys
- from watson_developer_cloud import SpeechToTextV1
- def transcribe_audio(audio_file_name) :
- IBM_USERNAME = "yourusername"
- IBM_PASSWORD = "yourpassword"
- #what changes should be made here instead of username and password
- stt = SpeechToTextV1(username=IBM_USERNAME, password=IBM_PASSWORD)
- audio_file = open(audio_file_name, "rb")
- json_file = os.path.abspath("america")+".json";
- with open(json_file, 'w') as fp:
- result = stt.recognize(audio_file,timestamps=True,content_type='audio/wav', inactivity_timeout =-1,word_confidence = True)
- result.get_result()
- json.dump(result, fp, indent=2)
- script = "Script is : "
- for rows in result['results']:
- script += rows['alternatives'][0]['transcript']
- print(script)
- transcribe_audio("america.wav")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement