Simplex Repeater (Parrot Repeater)

Simplex Repeaterとは

俗にいうオウム返しリピーター。
受信した音声を録音し、そのまま送り返す。
これをRaspberry Pi 2で作ります。

Webに掲載されている手順では足りない部分やVerが変わっている部分を補足して整理しました。

<注意>

RasPiとRaspbianの準備

GUIは不要なので、下記URLからRASPBIAN JESSIE LITEをダウンロードします。

RasPi2で動かしましたが、RasPi3でもPeaterPiPry2は動くと思います。
ただし、RasPi3ではUARTがBluetoothと喧嘩するためURATからLoginして作業するのはうまくいかない(文字化けする)かもしれません。
その場合はとりあえずUARTでログインしてSSHを有効にして、その後の作業はSSHでやるのが良いでしょう。

https://www.raspberrypi.org/downloads/raspbian/

ダウンロードしたらZip解凍して、Win32 DiskImager等でMicroSDカードにコピーします。
コピーが完了したら起動して、UARTまたはSSHでログインし、Updateを行います。

$ sudo apt-get update
$ sudo apt-get upgrade

再起動します。

PeaterPiPry2のセットアップ

PeaterPiPry2はPythonで動くスクリプトです。
これはもともとRaspberry Pi B(初期のもの)を対象としています。

順を追って必要なモジュールをインストールしていきます。

PeaterPiPry2を動かす前の準備

http://www.twotonedetect.net/twotonedetect-on-a-raspberry-pi/

ここに書いてある手順でいろいろなモジュールを入れていきます。

Pythonを入れる

$ sudo apt-get install python-setuptools
$ sudo apt-get install python-dev

Pythonのモジュール管理ツールpipを入れる

$ cd
$ mkdir pip
$ cd pip
$ wget https://pypi.python.org/packages/source/p/pip/pip-1.3.1.tar.gz
$ tar zxf pip-1.3.1.tar.gz
$ cd pip-1.3.1
$ sudo python setup.py install

Pythonモジュールの追加

$ sudo pip install Pycrypto
$ sudo pip install Iniparse
$ sudo pip install numpy

pyaudioの取得とインストール

$ cd
$ sudo apt-get install git
$ git clone http://people.csail.mit.edu/hubert/git/pyaudio.git
$ sudo apt-get install libportaudio0 libportaudio2 libportaudiocpp0 portaudio19-dev
$ sudo pip install pyaudio

ffmpegの取得とインストール(apt-getできないので手動で入れます)

$ cd
$ mkdir ffmpegtemp
$ cd ffmpegtemp
$ sudo su
# wget https://github.com/ccrisan/motioneye/wiki/precompiled/ffmpeg_2.8.3.git325b593-1_armhf.deb
# dpkg -i ffmpeg_2.8.3.git325b593-1_armhf.deb
# apt-get install libdc1394-22 libxvidcore-dev libav-tools libopencore-amrwb-dev libopencore-amrnb-dev
# exit
$

pulseaudioのインストール

$ sudo apt-get install pulseaudio
$ sudo apt-get install pavucontrol

pulseaudioの設定ファイルの修正

$sudo vi /etc/pulse/daemon.conf

;resample-method=speex-float-3
 ↑これを、
resample-method=trivial
 ↑こうする

PeaterPiPyr2のインストールとセットアップ

http://www.twotonedetect.net/raspberry-pi-simplex-repeater-the-peaterpipyr/

このページに従って作業すればよいのですが、ここから取得できる本体PeaterPiPyr2.pyはBUGっていて動きません。
次の手順でファイルを揃えます。

まず、パッケージを取得して展開します。

$ mkdir PeaterPiPyr2
$ cd PeaterPiPyr2
$ wget http://www.twotonedetect.net/downloads/simplexrepeater/PeaterPiPyr2.tgz
$ tar zxf PeaterPiPyr2.tgz

BUG FIXされたPeaterPiPyr2は次のURLから取得します。

https://github.com/teopost/RepeaterPi/blob/master/PeaterPiPyr2.py

取得したPeaterPiPyr2.pyを先のアーカイブに含まれていたPeaterPiPyr2.pyと差し替えます。

PeaterPiPyr2.pyの中身をいくつか修正します。
使用しているUSB-AudioはCreative Sound Blaster Play!2です。

$ vi PeaterPiPyr2.py

chunk = 4096
RATE = 44100

この2つの数値を変更します。
RATEはUSB-Audioが対応しているサンプリング周波数にします。
Sound Blaster Play!2は44100でないとエラーになります。
chunkはバッファーの大きさを指定していて、これもある程度大きくしないとBuffer Over Flow が発生して動きません。4096か8192あたりにします。

次に、/etc/pulse/daemon.confを修正します。

$ sudo vi /etc/pulse/daemon.conf

修正前:
; default-fragments = 4
; default-fragment-size-msec = 25

修正後:
default-fragments = 10
default-fragment-size-msec = 2

この値は、録音再生時に音がザザザザと変になる場合は調整が必要です。
デフォルトではだめでした。

最後にPeaterPiPyr2.pyのconfigファイルとTX.py RX.pyを修正します。
TX.pyとRX.pyににはPTT出力のピン指定があります。GPIO番号ではなく物理ピン番号で指定します。

config.cfgの例

[Section1]
audio_threshold = 150    ;音声検出の閾値
trigger_time = 0.2       ;録音スタートの音声時間(最低0.2秒)
record_seconds = 2.0     ;最低録音時間(0秒以上、7秒以下)
release_time = 2.0       ;無音検出時間(この時間以上無音が継続すると録音終了)
input_device_index = 2   ;入力デバイスID
output_device_index = 2  ;出力デバイスID

添付ファイル: filePeaterPiPyr.tgz 458件 [詳細]

トップ   編集 凍結 差分 バックアップ 添付 複製 名前変更 リロード   新規 一覧 検索 最終更新   ヘルプ   最終更新のRSS
Last-modified: 2023-11-27 (月) 23:39:34