File size: 593 Bytes
60dc67b
 
 
 
 
 
 
 
91f7830
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
import librosa
import soundfile as sf


def compress(audio_file):
    y, s = librosa.load(audio_file, sr=8000)  # Downsample 44.1kHz to 8kHz
    sf.write(audio_file, y, s, "PCM_24")
    return audio_file


# Define a helper function to convert credentials to dictionary
def credentials_to_dict(credentials):
    return {
        "token": credentials.token,
        "refresh_token": credentials.refresh_token,
        "token_uri": credentials.token_uri,
        "client_id": credentials.client_id,
        "client_secret": credentials.client_secret,
        "scopes": credentials.scopes,
    }