| 210 | |
| 211 | |
| 212 | def real_signal(): |
| 213 | spf = wave.open('helloworld.wav', 'r') |
| 214 | |
| 215 | #Extract Raw Audio from Wav File |
| 216 | # If you right-click on the file and go to "Get Info", you can see: |
| 217 | # sampling rate = 16000 Hz |
| 218 | # bits per sample = 16 |
| 219 | # The first is quantization in time |
| 220 | # The second is quantization in amplitude |
| 221 | # We also do this for images! |
| 222 | # 2^16 = 65536 is how many different sound levels we have |
| 223 | signal = spf.readframes(-1) |
| 224 | signal = np.fromstring(signal, 'Int16') |
| 225 | T = len(signal) |
| 226 | |
| 227 | hmm = HMM(10) |
| 228 | hmm.fit(signal.reshape(1, T)) |
| 229 | |
| 230 | |
| 231 | def fake_signal(init=simple_init): |