2

I have a signal in Python, and I want to hear it. This is possible?. The data is in the format numpy.ndarray.

In Matlab one can use the command sound(data,f).

Cris Luengo
  • 49,445
  • 7
  • 57
  • 113

2 Answers2

1

Yep! You can use scipy.io.wavfile library

import numpy as np
from scipy.io.wavfile import write
noise = np.random.uniform(-1,1,100000)
write('noise.wav', len(noise), noise)
MTT
  • 4,995
  • 7
  • 31
  • 55
  • 1
    We cannot run your example because the variable `data` is not defined. Please consider testing before posting. – Leonard Oct 05 '19 at 12:23
0

You can use the module soundfile:

import soundfile as sf

sf.write(filename.wav, data, samplerate)

For further information read the documentation.

Community
  • 1
  • 1
JoJo
  • 19
  • 2