0
0

pythonでgnuradio その23

Posted at

概要

pythonでgnuradioやってみた。
練習問題やってみた。

練習問題

vocoderを使え。

サンプルコード

from gnuradio import gr
from gnuradio import audio
from gnuradio import blocks
from gnuradio import filter
from gnuradio import vocoder

def build_graph():
	sample_rate = 8000
	scale_factor = 32000
	tb = gr.top_block()
	src = audio.source(sample_rate)
	src_scale = blocks.multiply_const_ff(scale_factor)
	interp = filter.rational_resampler_fff(8, 1)
	f2s = blocks.float_to_short()
	enc = vocoder.cvsd_encode_sb()
	dec = vocoder.cvsd_decode_bs()
	s2f = blocks.short_to_float()
	decim = filter.rational_resampler_fff(1, 8)
	sink_scale = blocks.multiply_const_ff(1.0 / scale_factor)
	sink = audio.sink(sample_rate)
	tb.connect(src, src_scale, interp, f2s, enc)
	tb.connect(enc, dec, s2f, decim, sink_scale, sink)
	return tb

if __name__ == '__main__':
	tb = build_graph()
	tb.start()
	input('Press Enter to exit: ')
	tb.stop()
	tb.wait()

以上。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0