You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I found I can save the audio to file in below code:
def callback_func(user, data):
global history_audio
audio = data.pcm
history_audio += audio
if len(history_audio) > 1000000:
tmp_audio = history_audio
history_audio = b''
audio_data = np.frombuffer(tmp_audio, dtype=np.int32, offset=0) # transfer types to numpy
sample_rate = 48000
scipy.io.wavfile.write(f'./voice_data/recoding_2.wav', sample_rate, audio_data) # save file
What make me surprise is I must read voiceData with format of np.int32 when transfer types to numpy, But the document of discord.py use np.int16(16-bit) as default, this is confusing if I am not wrong.
I try to save voiceData in format of bytes, but I cannot play it.
code:
saved file:
when I paly, the length of audio is 0.
If I check the file:
machin infor:
The text was updated successfully, but these errors were encountered: