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
  • 55,762
  • 10
  • 62
  • 120

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
  • 5,113
  • 7
  • 35
  • 61
  • 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