problems with parselmouth array based contructor

11 views
Skip to first unread message

Ekartle YaBoi

unread,
May 29, 2025, 11:57:49 PMMay 29
to yannick...@gmail.com, parse...@googlegroups.com
Hi Yannick

im working on a project to integrate parselmouth generated waveforms with a discord bot
in a nutshell you are supposed to upload audios to discord and then the bot gives you back the waveform for that audio
the
 issue I'm facing is that by the way discord hosting works i cant just save the file sent on discord and then upload it to parselmouth, i need to get its data from discord which can only save it to an  io.BufferedIOBase, and my idea was to save the attachment info to a BytesIO and then retrieve the data to praat using the  parselmouth.Sound(values: numpy.ndarray[numpy.float64] constructor, but it just doesnt want to work i get the bytes from the message and upload them to parselmouth and it just generates a weird wave form
for instance for the audio "men" it generates this wave form, all of this regardless of the array im pasing being both a ndarray and a float 64 as the constructor requires

here is the code im currently using, as well with some metacode added for further expalanation, i also added the bytes im getting to make clear that on the side of file to byte convertion everything is fine
        with BytesIO() as audio_buffer:

            await attachment_in_progress.save(fp= audio_buffer, use_cached = True)

            audio_array, sample_rate = sf.read(audio_buffer)
            print(type(audio_array))
            # <class 'numpy.ndarray'>
            print(audio_array.dtype)
            # float64
            #this is exactly what the constructor asks for
            #but still the wave form doesnt show up as intended

            bytes = audio_buffer.getvalue()
            print(bytes)
            #this doesnt throw any weird value either
            #it does the convertion of bytes to base64 perfectly, so the eror isnt there either
            print(type(audio_array))
            # <class 'numpy.ndarray'>
            print(audio_array.dtype)
            # float64

           
            byte_str = base64.b64encode(bytes)
            print(byte_str)
            # the bytestring is perfeclty fine as well
            print(type(audio_array))
            # <class 'numpy.ndarray'>
            print(audio_array.dtype)
            # <class 'numpy.ndarray'>

            sound =  parselmouth.Sound(values = audio_array, sampling_frequency = sample_rate, start_time=  float(0.0))

            plt.figure()
            plt.plot(sound.xs(), sound.values.T, color="#ff554d")
            plt.xlim([sound.xmin, sound.xmax])
python_yLPeCh3fQ0.png
men.mp3
Reply all
Reply to author
Forward
0 new messages