File size: 936 Bytes
1778490
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
29
30
31
32
33
34
35
import wave
import os


basePath = os.path.expanduser("~/Desktop/")


def convert_pcm_to_wav():
    # PCM file parameters (should match the parameters used to create the PCM file)
    pcm_file = basePath + 'output.pcm'
    wav_file = 'pcmconverted.wav'
    sample_rate = 16000  # Example: 16000 Hz
    channels = 1         # Example: 2 for stereo
    sample_width = 2     # Example: 2 bytes (16 bits), change if your PCM format is different

    # Read the PCM file and write to a WAV file
    with open(pcm_file, 'rb') as pcmfile:
        pcm_data = pcmfile.read()

    with wave.open(wav_file, 'wb') as wavfile:
        wavfile.setnchannels(channels)
        wavfile.setsampwidth(sample_width)
        wavfile.setframerate(sample_rate)
        wavfile.writeframes(pcm_data)

convert_pcm_to_wav()

# def generateCaptions(filepath):

# ! This might be redundant due to seamless-streaming



print(f"Converted {pcm_file} to {wav_file}")