Open E3V3A opened 6 years ago
As I wrote in Wiki,
If fails, You should find the way to use mic and speaker on your MagicMirror. But I cannot give you a help about that kind of problem.
Because there could be many reasons for not working sound system. I cannot guess which is the real problem. Well, sometimes I failed even in my own systems... :( I'm not an expert of that kind.
I have no idea how to set properly in your ALSA config. I don't know your types of devices and your current settings. but your problem looks like device number assign problem
.
Maybe https://www.raspberrypi.org/forums/viewtopic.php?t=124016 could be a help or at least beginning of solution.
Problem is that I'm able to play but I have no idea how the MMM-Assistant is using the sound devices.
arecord --device=hw:1,0 ....
It means this device is not configured as DEFAULT device, so
$ arecord -d 10 test6.wav && aplay test6.wav
doesn't work.
MM-Assistant use arecord
as default recorder and using it's default setting. so you should find way to set your target device as default device for your RPI.
And you have another options to use rec
or sox
. (See the record section in full version of configuration), but in that case, you also make your device as default of each sw.
@eouia Hi, yeah, I'm working on this now.
Seem different sound related modules, use different ALSA settings. rec
works on cli, for me, but I still need to try with Assistant. This now works:
# arecord -d 10 zz.wav && aplay zz.wav
Recording WAVE 'zz.wav' : Unsigned 8 bit, Rate 8000 Hz, Mono
Playing WAVE 'zz.wav' : Unsigned 8 bit, Rate 8000 Hz, Mono
But the default bitrate is very low, giving a very crappy recording. Using rec
is much better:
# rec zz1.wav && aplay zz1.wav
Input File : 'default' (alsa)
Channels : 2
Sample Rate : 48000
Precision : 16-bit
Sample Encoding: 16-bit Signed Integer PCM
In:0.00% 00:00:14.08 [00:00:00.00] Out:672k [ | ] Clip:0 ^C
Aborted.
Playing WAVE 'zz1.wav' : Signed 16 bit Little Endian, Rate 48000 Hz, Stereo
Hey @eouia
It's alive!! And its Awesome!
Ok here is the lowdown.
# cat ~/.asoundrc
# To ensure you don't have to specify the default *devices* (like `--device="hw:1,0"`).
pcm.!default {
type asym
playback.pcm {
type plug
slave.pcm "hw:1,0"
}
capture.pcm {
type plug
slave.pcm "hw:1,0"
}
}
# This set the default control options to use *hw* card #1
ctl.!default {
type hw
card 1
}
NOTE:
~/.asoundrc
, you must run sudo /etc/init.d/alsa-utils restart
to make it take effect!# aplay -l && arecord -l
**** List of PLAYBACK Hardware Devices ****
card 1: Set [C-Media USB Headphone Set], device 0: USB Audio [USB Audio]
Subdevices: 1/1
Subdevice #0: subdevice #0
**** List of CAPTURE Hardware Devices ****
card 1: Set [C-Media USB Headphone Set], device 0: USB Audio [USB Audio]
Subdevices: 1/1
Subdevice #0: subdevice #0
# cat /proc/asound/modules
1 snd_usb_audio
# cat /proc/asound/cards
1 [Set ]: USB-Audio - C-Media USB Headphone Set
C-Media USB Headphone Set at usb-3f980000.usb-1.5, full speed
Next, as I said above, rec
seem to work better out-of-the-box. But it is a wrapper for sox
so you need to ensure you have sox
+ dependencies installed. Then edit your full MMM-Assistant configuration config.js
. To this:
{
module: 'MMM-Assistant',
position: 'bottom_left',
config: {
assistant: {
auth: {
keyFilePath: "secret.json", // REQUIRED (Google Assistant API) -- OAuth2 x509 cert
savedTokensPath: "resources/tokens.js" // REQUIRED (Google Assitant API) -- accesss_token & refresh_token
},
audio: {
encodingIn: "LINEAR16", // Default. No need to change.
sampleRateOut: 16000 // Default. No need to change.
}
},
snowboy: {
models: [
{
file: "resources/smart_mirror.umdl", // This file define your MM wake word. (See doc notes.)
sensitivity: 0.5,
hotwords : "MIRROR" // Default model: "MIRROR". (This is not the wake word!)
},
{
file: "resources/snowboy.umdl", // This file define your GA wake word. (See doc notes.)
sensitivity: 0.5,
hotwords : "ASSISTANT" // Default model: "ASSISTANT". (This is not the wake word!)
}
]
},
record: {
threshold: 0, // Default. No need to change.
verbose:false, // Deafult: true -- for checking recording status.
recordProgram: 'rec', // You can use 'rec', 'sox', but we recommend 'arecord'
silence: 2.0 // Default. No need to change.
},
stt: {
auth: [{ // You can use multiple accounts to save money
projectId:'mmm-xx', // REQUIRED (Google Voice API) -- project_id
keyFilename: 'MMM-XX-aaaabbbbcccc.json' // REQUIRED (Google Voice API) -- service_account / private_key
}],
request: {
encoding: 'LINEAR16', // Default. No need to change.
sampleRateHertz: 16000, // Default. No need to change.
languageCode: 'en-US' // [en-US] To set the default GA speech request language.
// (See: https://cloud.google.com/speech/docs/languages)
},
},
speak: {
useAlert: true, // [true] Enable this to show the understood text of your speech
language: 'en-US', // [en-US] To set the default GA speech reply language.
},
alias: [ // You can use aliases for difficult pronunciation or easy using.
{
"help :command" : ["teach me :command", "what is :command"]
}
]
}
},
Then run MM with PM2 normally. To see the result of your voice input, follow the pm2 log files in a terminal with this:
# put this in your .bashrc for easy use
alias tailo='tail -f ~/.pm2/logs/mm-out-0.log'
tailo
...
Note, the wake words are smart mirror
(for MM control) and snowboy
(for GA).
Probably it would help to tune those files to your own voice, but I have no idea how to do that.
Next, I discovered a bug that freezes the Assistant module. See issue #25.
In the Wiki:
That fails with:
So then I tried with:
Since I only have an ALSA in
~/.asoundrc
, I guess MM never see my settings or they are not right. What are the settings you have?