| 238 | |
| 239 | |
| 240 | def real_signal(): |
| 241 | spf = wave.open('helloworld.wav', 'r') |
| 242 | |
| 243 | #Extract Raw Audio from Wav File |
| 244 | # If you right-click on the file and go to "Get Info", you can see: |
| 245 | # sampling rate = 16000 Hz |
| 246 | # bits per sample = 16 |
| 247 | # The first is quantization in time |
| 248 | # The second is quantization in amplitude |
| 249 | # We also do this for images! |
| 250 | # 2^16 = 65536 is how many different sound levels we have |
| 251 | signal = spf.readframes(-1) |
| 252 | signal = np.fromstring(signal, 'Int16') |
| 253 | T = len(signal) |
| 254 | |
| 255 | hmm = HMM(10) |
| 256 | hmm.fit(signal.reshape(1, T)) |
| 257 | |
| 258 | |
| 259 | def fake_signal(init=simple_init): |