GithubHelp home page GithubHelp logo

Comments (5)

E3V3A avatar E3V3A commented on August 26, 2024 1

Hey @eouia
It's alive!! And its Awesome!

Ok here is the lowdown.

  • If you are using an external USB soundcard for both your MIC input and SPEAKER output, then the ALSA config has to be like this:
# 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:

  1. This is surely not the only config that will work for you. As noted above, this config still default to a crappy bit-rate, but since it works, let's keep it simple like this for now.
  2. If you update/change your ~/.asoundrc, you must run sudo /etc/init.d/alsa-utils restart to make it take effect!
  • The other settings are:
# 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.

from mmm-assistant.

eouia avatar eouia commented on August 26, 2024

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.

from mmm-assistant.

E3V3A avatar E3V3A commented on August 26, 2024

Problem is that I'm able to play but I have no idea how the MMM-Assistant is using the sound devices.

from mmm-assistant.

eouia avatar eouia commented on August 26, 2024
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.

from mmm-assistant.

E3V3A avatar E3V3A commented on August 26, 2024

@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

from mmm-assistant.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.