1
3

リアルタイムで音響イベントをラズベリーパイ(Raspberry Pi4 B)で検出

Last updated at Posted at 2024-01-31

使用したデバイス

1.Raspberry Pi 4B(64-bit)
2.USB接続マイク(logicool C270n HD WEBCAM)

前準備

マイクのデバイスが認識しているか
参考サイト https://hellobreak.net/raspberry-pi-usb-microphone/

手順

ターミナルで以下のコードからgit cloneし、ファイルに移動。そしてrequirements.txtに書かれているライブラリをインストール
使用させて頂いたgit hub
https://github.com/robertanto/Real-Time-Sound-Event-Detection

git clone https://github.com/robertanto/Real-Time-Sound-Event-Detection.git
cd Real-Time-Sound-Event-Detection
pip3 install -r requirements.txt

インストールが完了したらThonnyかターミナルで実行
ターミナルの場合

python3 ./sound_event_detection.py

Thonnyの場合
git cloneしたファイルからsound_event_detection.pyを開いて実行
スクリーンショット 2024-01-31 11.05.28.png

実行できたら以下のような画面が出てくる
スクリーンショット 2024-01-31 11.02.29.png

初期の場合は
1. Speech(スピーチ)
2. Music(音楽)
3. Explosion(爆発?)
4. silence(無音)
の4つが設定されています。
設定を変更する場合は
sound_event_detection.pyの17行目の番号を変更

plt_classes = [0,132,420,494] # Speech, Music, Explosion, Silence 

Real-time-Sound-Event-Detection/keras_yamnet/yamnet_class_map.csv内を見て、欲しい項目の番号に変更
※git hubから閲覧可 英語で書かれているので翻訳で探してみるといいかも
https://github.com/robertanto/Real-Time-Sound-Event-Detection/blob/main/keras_yamnet/yamnet_class_map.csv
スクリーンショット 2024-01-31 11.37.37.png

1
3
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
1
3