mnakada / atomcam_tools

Hack tool for atomcam and wyzecam.
Other
183 stars 22 forks source link

CAMのスピーカーから任意の音(wav)を出力する機能について #23

Closed midori-mushi closed 2 years ago

midori-mushi commented 2 years ago

大変有用に利用させていただいています。

CAMのスピーカーから、事前に用意しておいた任意の音(wav)を出力する機能は無理でしょうか? (wavファイルをCAMに流し込んでWebUIのボタン押下で音出力、など)

今でも純正アプリの機能で、スマホのマイクからCAMのスピーカーへの音声出力が可能ですが、PC/マイコンから任意のトリガーでWebUI(の操作を疑似的に)操作して、CAMからwavを出力したいです。

→具体的には、条件を満たすと「こんにちは」とCAMから事前に用意していた音声を出力。

あるいは筋違いかと思いますが、もし現状のままでも実現できるヒントを、何かご教授いただけると大変ありがたいです。alsamixerではloopbackしか検出されず、aplayでの再生も無音です。 toolsのソースを拝見し、cmd.cgiにwebhookするとwebcmd.shが実行する仕組みを理解(および動作を確認)しましたので、もしaplayで再生できるようになれば、webcmd.shを書き換えて自力でも出来そうに思います。 ご検討をお願いいたします。

gtxaspec commented 2 years ago

does this binary work for you, playing audio .wav via command line?

https://github.com/gtxaspec/wz_mini_hacks/blob/master/SD_ROOT/wz_mini/bin/audioplay_t31

midori-mushi commented 2 years ago

Hello. Thank you for your suggestion. I copied it from the client with scp, chmod 777 and ran it, Did not work.

-sh: /root/audioplay_t31: not found

The output of the "file command"

audioplay_t31: ELF 32-bit LSB executable, MIPS, MIPS32 rel2 version 1 (SYSV), dynamically linked, interpreter /lib/ld-uClibc.so.0, stripped

gtxaspec commented 2 years ago

you may have to run this inside the atom chroot.

midori-mushi commented 2 years ago

Audioplay_t31 worked the way you taught me! appreciate. But unfortunately I get an error.

The wav file uses /wz_mini/usr/share/audio/init.wav.

/usr/sbin/audioplay_t31 /usr/sbin/init.wav 50 [INFO] : Playing the audio /usr/sbin/init.wav file. [INFO] : Volume is set to 50. Segmentation fault

gtxaspec commented 2 years ago

Ah, it seems it is incompatible for some reason. Here are the sources:

https://github.com/BiatuAutMiahn/IVSP-T31-1.1.1-20200508/blob/main/software/sdk/Ingenic-SDK-T31-1.1.1-20200508/samples/libimp-samples/sample-Ao.c

gtxaspec commented 2 years ago

it appears there is a problem, audioplay_t31 works when the audio.ko driver is loaded, but before iCamera is loaded. It seems that iCamera is blocking the audio app from working.

mnakada commented 2 years ago

I think iCamera_app is taking the IMPAudio mutex via localsdk so it cannot be executed from other processes. Maybe we need to add a command to libcallback to play audio via localsdk.

mnakada commented 2 years ago

The aplay command was added in Ver. 1.3.0.

usage: /scripts/cmd aplay /system/init/alarm.wav 40

or, from a remote host

curl -X POST -H 'Content-Type: application/json' -d '{"exec":"aplay /system/init/alarm.wav 40"}' --output - 'http://atomcam.local/cgi-bin/cmd.cgi?port=socket'
midori-mushi commented 2 years ago

早速のご対応ありがとうございます。 shellおよびWebAPIでの実行ができました! wavファイルは/atomの下に置いて、path指定/atom以下を指定するのですね

WebAPIについても機能実装ありがとうございます。 toolsのVerUPのたびにwebcmd.shを書き換える覚悟でいましたので助かります。 大変感謝いたします。

mnakada commented 2 years ago

SD-Card上にwaveFileを置いておけばupdateでも消えないです。 /media/mmc/hoge.wavでアクセスできます。 transcodeしていないので16bit/mono/PCM/8KHz以外のフォーマットはエラーになります。

midori-mushi commented 2 years ago

/media/mmc/ 試しました。こちらに置くと便利ですね。 wavフォーマットも了解しました。stereoや8KHz以外だとERRORになることを確認しました。

ありがとうございます。

midori-mushi commented 2 years ago

すいません。 今気づいたのですがwavファイルの最後1秒くらいが切れるように思います。

5秒、2秒のファイルを試しましたが、どちらも切れているようです。 サンプリングレートをツールで8KHzに変換しているので、その影響なのかもしれないのですが、 windowsでは変換前、変換後どちらも切れずに聞こえます。

https://www.hke.jp/products/voice/voice_audition.htm https://note.cman.jp/other/voice/

こちらのファイルをSoundEngineFreeで8KHzにしています。

mnakada commented 2 years ago

変換後のファイルを置いてもらう事は可能ですか? wave fileのフォーマットを簡易的にdecodeしているので、ファイルの構造が何か違う可能性があります。

それか、内部bufferと終了時の待ち時間の関係かもしれません。 bufferの吐き出しが完了してから停止処理するべきなのですが現状は固定で待って停止しています。 待ち時間が2秒なので、数秒のファイルだと起きないはずなのですが。 再生完了を待つ仕組みがあると思うので、ちょっとみてみます。

midori-mushi commented 2 years ago

human.zip 01.femal.zip

ありがとうございます、こちらになります。 よろしくお願いいたします。

mnakada commented 2 years ago

Ver.1.3.1で修正しました。

midori-mushi commented 2 years ago

早速のご対応ありがとうございます。 自システムに組み込み、有用に動いています。 大変感謝いたします。