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}")