7 steps to Converting Speech To Text with Python ☞ https://morioh.com/p/e0e5eb85a514?f=5c21fb01c16e2556b555ab32
#python #developer #PyAudio #tutorial
seen from Russia
seen from Canada
seen from United States
seen from China
seen from China
seen from Saudi Arabia
seen from United States
seen from China

seen from Mauritania
seen from India
seen from United States

seen from China
seen from El Salvador

seen from Türkiye
seen from Costa Rica
seen from Saudi Arabia

seen from Vietnam
seen from Sweden
seen from Cambodia
seen from Netherlands
7 steps to Converting Speech To Text with Python ☞ https://morioh.com/p/e0e5eb85a514?f=5c21fb01c16e2556b555ab32
#python #developer #PyAudio #tutorial
Programming meets Voice Recording: A Python Guide for Playing and Capturing Sound
Machine learning seems cool and interesting when you see the model in action. What many people don’t reveal is that training and optimizing one is tiresome, especially when you have to tune the hyperparameters. The training process could go on for a couple of minutes and waiting every time for the model to finish learning the data gets boring fast. But there should be a solution to this. What if…
View On WordPress
raspberryPi と pyaudioで録音、音声波形処理
raspberryPiにマイク付きUSBカメラ(C270)を接続して録音したりDC成分とったり。安定動作のため、raspberryPiはこちらの電源環境で動かしています。
1.RaspberryPiのサウンドデバイス設定を行う。
参考URL:Pyaudio - Recording sound on Pi - getting errors
[Ubuntu] オーディオデバイス番号を固定化する
$ arecord -l
でオーディオデバイスの確認、C270又はその他のUSBマイクを繋いでいれば以下のように表示される。ここでは「device 0」の部分がデバイス番号。
(※:うちのraspberryPiでは、起動前にC270を繋いでおく必要がありました)
**** List of CAPTURE Hardware Devices **** card 0: U0x46d0x825 [USB Device 0x46d:0x825], device 0: USB Audio [USB Audio] Subdevices: 1/1 Subdevice #0: subdevice #0
上記のデバイス番号を元に
/etc/modprobe.d/alsa-base.conf
内の
options snd-usb-audio index=-2
を
options snd-usb-audio index=0
又は、arecordで表示されたデバイス番号に変更。
2.設定した内容で録音テスト
$ arecord -f S16_LE -r 44100 -D hw:0,0 record.wav
上記コマンドで44100Hzサンプリング、0番デバイス、ファイル名「record.wav」で録音します。ctrl+Cで録音停止。録音されたファイルを再生して、音がしっかりと録音できいれば素晴らしい。私はSMBサーバを使ってwindwosから再生し確認しました。raspberryPiから再生する場合はオーディオジャックにUSBスピーカなどを繋いで
$aplay -l
でマイクと同じようにデバイスを探し、デバイス番号に合わせて
$aplay -D plughw:1,0 record.wav
で再生します。
3.pyaudioを入れる
sudo apt-get install python-pyaudio
4.プログラム実行
># -*- coding: utf-8 -*- #マイク0番からの入力を受ける。一定時間(RECROD_SECONDS)だけ録音し、ファイル名:mono.wavで保存する。 import pyaudio import sys import time import wave if __name__ == '__main__': chunk = 1024 FORMAT = pyaudio.paInt16 CHANNELS = 1 #サンプリングレート、マイク性能に依存 RATE = 44100 #録音時間 RECORD_SECONDS = input('Please input recoding time>>>') #pyaudio p = pyaudio.PyAudio() #マイク0番を設定 input_device_index = 0 #マイクからデータ取得 stream = p.open(format = FORMAT, channels = CHANNELS, rate = RATE, input = True, frames_per_buffer = chunk) all = [] for i in range(0, RATE / chunk * RECORD_SECONDS): data = stream.read(chunk) all.append(data) stream.close() data = ''.join(all) out = wave.open('mono.wav','w') out.setnchannels(1) #mono out.setsampwidth(2) #16bits out.setframerate(RATE) out.writeframes(data) out.close() p.terminate()
実行し録音時間を入力するとmono.wavとして録音結果を出力する。
実行時に警告が沢山出ますがエラーでなければ動きます。
input overflow
などのエラーで止まってしまう時は、RATE=44100の部分をマイクのサンプリング周波数に合わせてから、何度か実行してみてください。
DC成分については長くなったので別記します。
Playing with PyAudio. Pretty simple results so far, but I'm sure something good can come of it.