@@ -0,0 +1,1644 @@
+%22%22%22%0ATakes the filename of a preprocessed spectrogram and creates the sound file%0Athat created it.%0A%22%22%22%0Aimport audiosegment as asg%0Aimport os%0Aimport sys%0A%0Adef segment_from_specname(specfname: str) -%3E asg.AudioSegment:%0A    %22%22%22%0A    Returns an AudioSegment object that corresponds to the given spectrogram filename.%0A    %22%22%22%0A    specfname = os.path.basename(specfname)         # english_10240.wav_21.png%0A%0A    wavindex_plus_png = specfname.split('_')%5B-1%5D    # 21.png%0A    wavindex = int(wavindex_plus_png.split('.')%5B0%5D) # 21%0A%0A    wavfname = specfname.split('.')%5B0%5D + %22.wav%22     # english_10240.wav%0A    wavfpath = %22/media/max/seagate8TB/thesis_audio/preprocessed_gold_data/%22 + wavfname%0A%0A    if not os.path.isfile(wavfpath):%0A        raise ValueError(%22Cannot find file: %7B%7D%22.format(wavfpath))%0A%0A    sample_rate_hz  = 16000.0    # 16kHz sample rate%0A    bytewidth       = 2          # 16-bit samples%0A    nchannels       = 1          # mono%0A    seg = asg.from_file(wavfpath)%0A    segments = seg.dice(0.5)%0A    for i, s in enumerate(segments):%0A        if i == wavindex:%0A            return s.resample(sample_rate_hz, bytewidth, nchannels)%0A    raise ValueError(%22After dicing by 0.5 seconds, can't find index segment indexed %7B%7D%22.format(wavindex))%0A%0Aif __name__ == %22__main__%22:%0A    if len(sys.argv) != 2:%0A        print(%22USAGE: python %7B%7D %3Cpath-to-preprocessed-spectrogram%3E%22.format(sys.argv%5B0%5D))%0A        exit(1)%0A    elif not os.path.isfile(sys.argv%5B1%5D):%0A        print(%22USAGE: python %7B%7D %3Cpath-to-preprocessed-spectrogram%3E%22.format(sys.argv%5B0%5D))%0A        exit(2)%0A%0A    seg = segment_from_specname(sys.argv%5B1%5D)%0A    seg.export(os.path.basename(sys.argv%5B1%5D) + %22.wav%22, format=%22WAV%22)%0A

Add sound.py