Skip to content

Instantly share code, notes, and snippets.

View gmyrianthous's full-sized avatar

Giorgos Myrianthous gmyrianthous

View GitHub Profile
@gmyrianthous
gmyrianthous / topic_detection.py
Created February 8, 2022 15:28
Topic Detection with Python - Part 4
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
@gmyrianthous
gmyrianthous / topic_detection.py
Created February 8, 2022 15:06
Topic Detection with Python - Part 2
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:
@gmyrianthous
gmyrianthous / topic_detection.py
Created February 8, 2022 15:02
Topic Detection with Python - Part 1
import requests
API_KEY = <your AssemblyAI API key goes here>
# Create the headers for request
headers = {
'authorization': API_KEY,
'content-type': 'application/json'
}
@gmyrianthous
gmyrianthous / speech_to_text_pii_removal.py
Created January 30, 2022 17:52
Speech-to-Text and PII removal - Full Code
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'
@gmyrianthous
gmyrianthous / response.json
Created January 30, 2022 17:46
Speech-to-Text and PII removal - Response
{
"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,
@gmyrianthous
gmyrianthous / speech_to_text_pii_removal.py
Created January 30, 2022 17:37
Speech-to-Text and PII removal - Part 5
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}')
@gmyrianthous
gmyrianthous / speech_to_text_pii_removal.py
Created January 30, 2022 17:35
Speech-to-Text and PII removal - Part 4
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
@gmyrianthous
gmyrianthous / speech_to_text_pii_removal.py
Created January 30, 2022 17:31
Speech-to-Text and PII removal - Part 3
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',
},
@gmyrianthous
gmyrianthous / speech_to_text_pii_removal.py
Created January 30, 2022 16:30
Speech-to-Text and PII removal - Part 2
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: