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" | |
| response = requests.post(transcript_endpoint, | |
| headers=headers, | |
| json={ | |
| "audio_url": audio_url, | |
| "sentiment_analysis": True, | |
| }) | |
| transcript_id = response.json()['id'] |
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
| # STEP 1: UPLOAD YOUR AUDIO FILE AND GET URL | |
| import requests | |
| filename = '/Users/frankandrade/Desktop/Steve Jobs.mp3' # Your path goes here | |
| api_key = # Your API key goes here | |
| upload_endpoint = 'https://api.assemblyai.com/v2/upload' | |
| def read_file(filename, chunk_size=5242880): | |
| with open(filename, 'rb') as f: | |
| while True: |
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
| # STEP 3: SAVE THE TRANSCRIPT AND SUMMARY | |
| import os | |
| import sys | |
| import time | |
| import json | |
| polling_endpoint = os.path.join(transcript_endpoint, transcript_id) | |
| status = '' | |
| while status != 'completed': |
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" | |
| response = requests.post(transcript_endpoint, | |
| headers=headers, | |
| json={ | |
| "audio_url": audio_url, | |
| "auto_chapters": True | |
| }) | |
| transcript_id = response.json()['id'] |
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
| # STEP 1: UPLOAD YOUR AUDIO FILE AND GET URL | |
| import requests | |
| filename = '/Users/frankandrade/Desktop/Steve Jobs.mp3' # Your path goes here | |
| api_key = # Your API key goes here | |
| upload_endpoint = 'https://api.assemblyai.com/v2/upload' | |
| def read_file(filename, chunk_size=5242880): | |
| with open(filename, 'rb') as f: | |
| while True: |
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 websockets | |
| import asyncio | |
| import base64 | |
| import json | |
| from configure import auth_key | |
| # the AssemblyAI endpoint we're going to hit | |
| URL = "wss://api.assemblyai.com/v2/realtime/ws?sample_rate=16000" | |
| async def send_receive(): |
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 pyaudio | |
| FRAMES_PER_BUFFER = 3200 | |
| FORMAT = pyaudio.paInt16 | |
| CHANNELS = 1 | |
| RATE = 16000 | |
| p = pyaudio.PyAudio() | |
| # starts recording | |
| stream = p.open( |
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
| # Imported StudentsPerformance_id.csv | |
| import pandas as pd | |
| StudentsPerformance_id_csv = pd.read_csv(r'StudentsPerformance_id.csv') | |
| # Imported LanguageScore.csv | |
| import pandas as pd | |
| LanguageScore_csv = pd.read_csv(r'LanguageScore.csv') | |
| # Merged LanguageScore_csv and StudentsPerformance_id_csv | |
| temp_df = StudentsPerformance_id_csv.drop_duplicates(subset='id') # Remove duplicates so lookup merge only returns first match | |
| df3 = LanguageScore_csv.merge(temp_df, left_on=['id'], right_on=['id'], how='left', suffixes=['_LanguageScore_csv', '_StudentsPerformance_id_csv']) |
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
| # Imported StudentsPerformance.csv | |
| import pandas as pd | |
| StudentsPerformance_csv = pd.read_csv(r'StudentsPerformance.csv') | |
| # Pivoted StudentsPerformance_csv into df2 | |
| unused_columns = StudentsPerformance_csv.columns.difference(set(['race/ethnicity']).union(set([])).union(set({'math score', 'reading score'}))) | |
| tmp_df = StudentsPerformance_csv.drop(unused_columns, axis=1) | |
| pivot_table = tmp_df.pivot_table( | |
| index=['race/ethnicity'], | |
| values=['math score', 'reading score'], | |
| aggfunc={'math score': ['mean'], 'reading score': ['mean']} |
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
| # Filtered gender in StudentsPerformance_csv | |
| StudentsPerformance_csv = StudentsPerformance_csv[StudentsPerformance_csv['gender'] == 'female'] | |
| # Filtered race/ethnicity in StudentsPerformance_csv | |
| StudentsPerformance_csv = StudentsPerformance_csv[StudentsPerformance_csv['race/ethnicity'] == 'group B'] |