本文整理汇总了Python中Analyzer.Analyzer.encode方法的典型用法代码示例。如果您正苦于以下问题:Python Analyzer.encode方法的具体用法?Python Analyzer.encode怎么用?Python Analyzer.encode使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Analyzer.Analyzer
的用法示例。
在下文中一共展示了Analyzer.encode方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: record_and_play_audio
# 需要导入模块: from Analyzer import Analyzer [as 别名]
# 或者: from Analyzer.Analyzer import encode [as 别名]
def record_and_play_audio():
record_seconds = 5
fs = 44100
p = pyaudio.PyAudio()
odata = np.zeros(fs * record_seconds)
print "Recording audio for the next {0} seconds".format(record_seconds)
record_audio(odata, p, fs, record_seconds)
wavio.write("before.wav", 44100, odata)
print "Audio has recorded, stand by for voice"
play_audio(odata, p, fs)
print "Encoding and decoding voice through vocoder"
analyzer = Analyzer(odata, 10e-3)
lpc_frame_array = analyzer.encode()
synthesizer = Synthesizer(lpc_frame_array)
reconstructed_signal = synthesizer.decode()
wavio.write("test.wav", 441000, reconstructed_signal)
print "Playing reconstructed audio"
play_audio(reconstructed_signal, p, fs)
p.terminate()