File size: 716 Bytes
60dc67b
 
 
 
 
2ef4f3c
 
 
 
 
60dc67b
2ef4f3c
 
 
 
 
 
60dc67b
2ef4f3c
60dc67b
2ef4f3c
60dc67b
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
import librosa
from pathlib import Path, PurePath
import soundfile as sf


# def serialize(messages):
#     """
#     Converts a list of tuples where each element of the list represents a message to dictionary of
#     messages
#     """

#     serialized_messages = []
#     for message in messages:
#         serialized_message = [
#             {"role": "system", "content": message[0]},
#             {"role": "user", "content": message[1]},
#         ]

#         serialized_messages.extend(serialized_message)

#     return serialized_messages


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