File size: 897 Bytes
19f8ea7 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
#!/usr/bin/python3
# -*- coding: utf-8 -*-
from typing import List
import matplotlib.pyplot as plt
import numpy as np
def process_speech_probs(signal: np.ndarray, speech_probs: List[float], frame_step: int) -> np.ndarray:
speech_probs_ = list()
for p in speech_probs[1:]:
speech_probs_.extend([p] * frame_step)
pad = (signal.shape[0] - len(speech_probs_))
speech_probs_ = speech_probs_ + [0.0] * pad
speech_probs_ = np.array(speech_probs_, dtype=np.float32)
if len(speech_probs_) != len(signal):
raise AssertionError
return speech_probs_
def make_visualization(signal: np.ndarray, speech_probs, sample_rate: int):
time = np.arange(0, len(signal)) / sample_rate
plt.figure(figsize=(12, 5))
plt.plot(time, signal, color='b')
plt.plot(time, speech_probs, color='gray')
plt.show()
return
if __name__ == "__main__":
pass
|