Tôi cần theo dõi âm thanh đường dây trong trong linux và trong trường hợp âm thanh được phát, âm thanh phải được ghi lại và lưu vào tệp. Tương tự như cách motion theo dõi nguồn cấp dữ liệu video.Giám sát đường âm thanh
Có thể thực hiện điều này bằng bash không? cái gì đó dọc theo dòng:
#!/bin/bash
# audio device
device=/dev/audio-line-in
# below this threshold audio will not be recorded.
noise_threshold=10
# folder where recordings are stored
storage_folder=~/recordings
# run indefenitly, until Ctrl-C is pressed
while true; do
# noise_level() represents a function to determine
# the noise level from device
if noise_level($device) > $noise_threshold; then
# stream from device to file, can be encoded to mp3 later.
cat $device > $storage_folder/$(date +%FT%T).raw
fi;
done;
EDIT: Dòng chảy Tôi muốn nhận được từ chương trình này là
a. when noise > threshold, start recording
b. stop recording when noise < threshold for 10 seconds
c. save recorded piece to separate file
Không bao giờ nghe nói về chuyển động trước, đẹp nhất –
Kết quả mặc định của 'ngày' có khoảng trống trong đó. Nó sẽ là tốt hơn để sử dụng một cái gì đó như '$ (ngày +% FT% T)' trông giống như: "2010-04-10T08: 55: 56" do đó, nó sắp xếp và không có không gian. [ISO 8601] (http://www.iso.org/iso/support/faqs/faqs_widely_used_standards/widely_used_standards_other/date_and_time_format.htm) (và [tại đây] (http://en.wikipedia.org/wiki/ISO_8601)) –
@ Dennis, thanx, đã thay đổi điều đó. – Stefan