This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import os | |
| import sys | |
| from time import sleep | |
| status = '' | |
| while status != 'completed': | |
| res_result = requests.get( | |
| os.path.join(TRANSCRIPT_ENDPOINT, res_transcript_json['id']), | |
| headers=headers |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| AUDIO_FILE = '/path/to/your/audio/file.mp3' | |
| UPLOAD_ENDPOINT = 'https://api.assemblyai.com/v2/upload' | |
| def read_audio_file(file): | |
| """Helper method that reads in audio files""" | |
| with open(file, 'rb') as f: | |
| while True: | |
| data = f.read(5242880) | |
| if not data: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import requests | |
| API_KEY = <your AssemblyAI API key goes here> | |
| # Create the headers for request | |
| headers = { | |
| 'authorization': API_KEY, | |
| 'content-type': 'application/json' | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import os | |
| import sys | |
| import requests | |
| from time import sleep | |
| API_KEY = <your AssemblyAI API key goes here> | |
| AUDIO_FILE = '/path/to/your/audio/file.mp3' | |
| UPLOAD_ENDPOINT = 'https://api.assemblyai.com/v2/upload' | |
| TRANSCRIPT_ENDPOINT = 'https://api.assemblyai.com/v2/transcript' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| { | |
| "acoustic_model": "assemblyai_default", | |
| "audio_duration": 11, | |
| "audio_end_at": null, | |
| "audio_start_from": null, | |
| "audio_url": "https://cdn.assemblyai.com/upload/b017e8c0-b31a-4d09-9dc2-8dee0ee0d3c8", | |
| "auto_highlights": false, | |
| "auto_highlights_result": null, | |
| "boost_param": null, | |
| "confidence": 0.80822375, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| OUTPUT_TRANSCRIPT_FILE = 'speech-to-text-tutorial.txt' | |
| with open(OUTPUT_TRANSCRIPT_FILE, 'w') as f: | |
| f.write(res_result.json()['text']) | |
| print(f'Transcript file saved under {OUTPUT_TRANSCRIPT_FILE}') |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import os | |
| import sys | |
| from time import sleep | |
| status = '' | |
| while status != 'completed': | |
| res_result = requests.get( | |
| os.path.join(TRANSCRIPT_ENDPOINT, res_transcript_json['id']), | |
| headers=headers |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| TRANSCRIPT_ENDPOINT = 'https://api.assemblyai.com/v2/transcript' | |
| res_transcript = requests.post( | |
| TRANSCRIPT_ENDPOINT, | |
| headers=headers, | |
| json={ | |
| 'audio_url': upload_url, | |
| 'redact_pii': True, | |
| 'redact_pii_sub': 'entity_name', | |
| }, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| AUDIO_FILE = '/path/to/your/audio/file.mp3' | |
| UPLOAD_ENDPOINT = 'https://api.assemblyai.com/v2/upload' | |
| def read_audio_file(file): | |
| """Helper method that reads in audio files""" | |
| with open(file, 'rb') as f: | |
| while True: | |
| data = f.read(5242880) | |
| if not data: |