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])