Coder Social home page Coder Social logo

mycroftai / skill-volume Goto Github PK

View Code? Open in Web Editor NEW
10.0 8.0 30.0 222 KB

Mycroft AI official Volume Skill - control the volume of your Device

Home Page: https://mycroft.ai/skills

License: Apache License 2.0

Python 76.07% Gherkin 23.93%
mycroft mycroftai mycroft-skill volume volume-control sound hacktoberfest

skill-volume's Introduction

Volume Control

Control the volume of your system

About

Control the volume of Mycroft with verbal commands or by spinning the physical button on a Mark 1.

Examples

  • "Turn up the volume"
  • "Decrease the audio"
  • "Mute audio"
  • "Set volume to 5"
  • "Set volume to 75 percent"

Credits

Mycroft AI (@MycroftAI)

Category

Configuration

Tags

#volume #volume-control #sound #system

skill-volume's People

Contributors

aleale99 avatar augustnmonteiro avatar benklop avatar chrisveilleux avatar colla69 avatar dave-esch avatar davidwagnerkc avatar devs-mycroft avatar dschweppe avatar e-gor avatar forslund avatar goldyfruit avatar gras64 avatar jimvine avatar kathyreid avatar krisgesling avatar learnedvector avatar luke5sky avatar matthewscholefield avatar ndato avatar penrods avatar putnik avatar spagy avatar tony763 avatar zeehio avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

skill-volume's Issues

upon unmute volume is always reset to 6

i set the volume to maximum level. --> succeeded
volume mute --> succeeded, volume muted
volume unmute --> volume reset to 6

instead of resetting back to 6 every time, it should have return to the previous volume state

using mycroft on cli mode
--> mycroft core version 2002 release 4
--> platform : Linux Mint 19.1

This is my first hand experience with open-source project, please let me know if any other information are required .

VolumeSkill race condition causing Mycroft to stay muted forever

Sometimes, when saying "Hey Mycroft" while Mycroft hasn't yet restored the volume will trigger the VolumeSkill again and cause it to believe the last known volume was 0. This causes the VolumeSkill to "restore" the volume to 0 when unmuting, effectively keeping Mycroft muted forever until the user manually restores the volume setting in ALSA/PulseAudio.

  • I'm running Picroft
  • With version 19.8.5 of the Mycroft software
  • With the standard Wake Word

Try to provide steps that we can use to replicate the Issue

For example:

  1. Install the Spotify skill
  2. Say "Hey Mycroft"
  3. Wait for Mycroft to beep
  4. Say "Play the album proxy by Being as an Ocean"
  5. Say "Hey Mycroft" again
  6. Mycroft stays muted until manually restoring the ALSA settings.

Be as specific as possible about the expected condition, and the deviation from expected condition.

Expected: Mycroft sets its volume back to the previous level
Actual: Mycroft sets its volume back to 0

Provide log files or other output to help us see the error

Pay special attention to the output of VolumeSkill:

Establishing Mycroft Messagebus connection...                                                                                                                               
Connected to Messagebus!                                                                                                                                                    
 20:11:12.128 | INFO     | 20468 | mycroft.skills.skill_loader:_communicate_load_status:278 | Skill mycroft-spotify.forslund loaded successfully                            
 20:11:12.150 | INFO     | 20468 | mycroft.skills.skill_manager:put:73 | Updating settings meta during runtime...                                                           
 20:11:12.153 | INFO     | 20468 | mycroft.skills.padatious_service:train:89 | Training complete.                                                                           
 20:11:12.159 | INFO     | 20468 | msm.mycroft_skills_manager | invalidating skills cache                                                                                   
 20:11:12.161 | INFO     | 20468 | msm.mycroft_skills_manager | building SkillEntry objects for all skills                                                                  
 20:11:21.488 | INFO     | 20468 | mycroft.skills.skill_manager:send:60 | New Settings meta to upload.                                                                      
 20:11:25.462 | INFO     | 20474 | __main__:handle_wakeword:59 | Wakeword Detected: hey mycroft                                                                             
Playing WAVE '/home/pi/mycroft-core/mycroft/res/snd/start_listening.wav' : Signed 16 bit Little Endian, Rate 48000 Hz, Stereo                                               
 20:11:25.960 | INFO     | 20474 | __main__:handle_record_begin:37 | Begin Recording...                                                                                     
 20:11:29.365 | INFO     | 20474 | __main__:handle_record_end:43 | End Recording...                                                                                         
 20:11:25.967 | INFO     | 20468 | VolumeSkill | MUTING!                                                                                                                    
55                                                                                                                                                                          
 20:11:25.968 | INFO     | 20468 | AlarmSkill | on started...                                                                                                               
 20:11:29.481 | INFO     | 20468 | AlarmSkill | on ended...                                                                                                                 
 20:11:31.160 | INFO     | 20468 | VolumeSkill | Volume before mute: 55                                                                                                     
 20:11:31.160 | INFO     | 20468 | VolumeSkill | 55                                                                                                                         
 20:11:31.569 | INFO     | 20474 | __main__:handle_utterance:64 | Utterance: ['play the album proxy by being as an ocean']                                                  
 20:11:46.583 | INFO     | 20474 | __main__:handle_wakeword:59 | Wakeword Detected: hey mycroft                                                                             
Playing WAVE '/home/pi/mycroft-core/mycroft/res/snd/start_listening.wav' : Signed 16 bit Little Endian, Rate 48000 Hz, Stereo                                               
0                                                                                                                                                                           
 20:11:47.523 | INFO     | 20468 | VolumeSkill | MUTING!                                                                                                                    
 20:11:47.476 | INFO     | 20474 | __main__:handle_record_begin:37 | Begin Recording...                                                                                     
 20:11:47.523 | INFO     | 20468 | AlarmSkill | on started...                                                                                                               
 20:11:47.568 | INFO     | 20468 | VolumeSkill | Volume before mute: 0                                                                                                      
 20:11:47.569 | INFO     | 20468 | VolumeSkill | 0                                                                                                                          
0                                                                                                                                                                           
 20:11:47.589 | INFO     | 20468 | Playback Control Skill | Resolving Player for: the album proxy by being as an ocean                                                      
 20:11:47.744 | INFO     | 20474 | __main__:handle_record_end:43 | End Recording...                                                                                         
Removing event mycroft-playback-control.mycroftai:PlayQueryTimeout                                                                                                          
Removing event mycroft-playback-control.mycroftai:PlayQueryTimeout                                                                                                          
Removing event mycroft-playback-control.mycroftai:PlayQueryTimeout                                                                                                          
 20:11:47.787 | INFO     | 20468 | AlarmSkill | on ended...                                                                                                                 
0                                                                                                                                                                           
 20:11:47.887 | INFO     | 20468 | SpotifySkill | ('proxy', 'proxy: an a.n.i.m.o. story', 0.5225806451612903)                                                               
 20:11:47.888 | INFO     | 20468 | SpotifySkill | Spotify confidence: 0.5225806451612903                                                                                    
~~~~'type': 'album', 'uri': 'spotify:album:5DBBejLG3BjEylQNDbQWsT'}], 'limit': 10, 'next': None, 'offset': 0, 'previous': None, 'total': 1}}, 'name': None, 'type': 'album'}
~~~~:47.895 | INFO     | 20468 | mycroft.skills.settings:save_settings:109 | Skill settings successfully saved to /opt/mycroft/skills/mycroft-spotify.forslund/settings.json
Removing event mycroft-playback-control.mycroftai:PlayQueryTimeout                                                                                                          
 20:11:52.302 | INFO     | 20468 | Playback Control Skill | Playing with: mycroft-spotify.forslund                                                                          
 20:11:52.566 | INFO     | 20468 | Playback Control Skill | Audio service status: {}                                                                                        
 20:11:52.767 | INFO     | 20468 | SpotifySkill | Device detected: DeviceType.MYCROFT                                                                                       
 20:11:53.483 | INFO     | 20468 | SpotifySkill | playing album                                                                                                             
 20:11:55.492 | INFO     | 20468 | SpotifySkill | spotify_play: 039a0c66d9e426f038c08cbe1926ab002b3ef6a9                                                                    
Removing event mycroft-spotify.forslund:MonitorSpotify                                                                                                                      
 20:11:59.775 | INFO     | 20468 | mycroft.skills.padatious_service:train:87 | Training... (single_thread=False)                                                            

missing requirement

This happened to me when upgrading to ubuntu 20, it didnt happen before so i think this package used to be installed by default

adding pyalsaaudio to requirements.txt should fix it

Logs bellow from a mint install, see MycroftAI/mycroft-core#2609 (comment)

 04:17:55.874 | ERROR    | 15570 | mycroft.skills.skill_loader:_load_skill_source:215 | Failed to load skill: mycroft-volume.mycroftai (ModuleNotFoundError("No module named 'alsaaudio'",))
Traceback (most recent call last):
  File "/home/florin/snap/mycroft/common/venv/lib/python3.6/site-packages/mycroft/skills/skill_loader.py", line 208, in _load_skill_source
    ('.py', 'rb', imp.PY_SOURCE)
  File "/snap/mycroft/current/usr/lib/python3.6/imp.py", line 235, in load_module
    return load_source(name, filename, file)
  File "/snap/mycroft/current/usr/lib/python3.6/imp.py", line 172, in load_source
    module = _load(spec)
  File "<frozen importlib._bootstrap>", line 684, in _load
  File "<frozen importlib._bootstrap>", line 665, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 678, in exec_module
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "/home/florin/snap/mycroft/1078/../common/mycroft-data/skills/mycroft-volume.mycroftai/__init__.py", line 15, in <module>
    from alsaaudio import Mixer, mixers as alsa_mixers
ModuleNotFoundError: No module named 'alsaaudio'

python version does not seem relevant, i can replicate using python 3.8, logs above indicate python 3.6

When changing volume, Mycroft should confirm with sound not words

  • Replace dialog with sound at the new volume level
    • That includes increase, decrease, mute, reset, set
    • Use same sound as when turning top button to change volume
  • Keep max volume dialog
  • Keep dialog in situations when user specifically asks for volume level, eg. "HM, what's your volume level?"
  • Keep visual indication in Mark I eyes

Redesign intent Mute/Unmute

  • Cover "Hey Mycroft mute" use case, without requiring "audio", "volume" etc. (Volume.voc) in the phrase. I.e. allow both "HM mute" as well as "HM mute audio" etc.

  • Remove "silence" from the mute intent and let "HM silence" and "HM silence audio" be handled by the Stop skill. Saying "silence" usually isn't intended to mute, just to stop.

  • In the same way as with mute intent, allow "HM unmute" without requiring "audio" or "volume" in the phrase.

  • Make "reset" from the Unmute.voc work not as unmute but to reset the audio level to default (I think it's 6), i.e. as a different intent. (Keep "restore" +Volume.voc as unmute intent.)

  • Make Mycroft not reply "Audio is going to be muted", just go to muted state without saying anything and...

  • Indicate the muted state visually, see picture (Mark I face):

mark1-face-mute

Cannot modify the volume to Picroft

Hi,

I copied the latest image of the Picroft for a Raspberry pi 3 B+, but I cannot set the Volume.
It seems there's a problem with the skill since i can manually set the volume from python command line.
https://github.com/MycroftAI/enclosure-picroft/tree/stretch

I get this following error:

Traceback (most recent call last):
File "/home/pi/mycroft-core/mycroft/skills/core.py", line 707, in wrapper
handler(message)
~~~~/skills/mycroft-volume.mycroftai/__init__.py", line 95, in handle_set_volume
level = self.__get_volume_level(message, self.mixer.getvolume()[0])
AttributeError: 'VolumeSkill' object has no attribute 'mixer'

Can anybody help me?

Inconsistent sound control(userspace) throughout Mycroft software stack.

Who is doing what? Using which userspace sound system?

Linux and sound is and has always been a pain in the @$$ if you ask me personally. Sound control within the Mycroft software stack is no exception, although A LOT has been improved lately. However at the moment there are some inconsistencies in who is doing what and by using which userland system.

I would like to open a dialog about this, your ideas and figure out the best way forward.

Information

At this moment we can force mycroft-core to use PulseAudio by changing;

"play_wav_cmdline": "aplay -Dhw:0,0 %1"
"play_mp3_cmdline": "mpg123 -a hw:0,0 %1"

to;

"play_wav_cmdline": "aplay %1"
"play_mp3_cmdline": "mpg123 %1"

This all works fine, and WAV and MP3 are played using the default sink of PulseAudio. However the volume control of mycroft itself is handled by this skill (hence the reason I open the dialog here), BUT is forced to use ALSA and its mixers or nothing at all.

Looking at the code of the skill, there are a couple things that jump out;
https://github.com/MycroftAI/skill-volume/blob/19.08/__init__.py#L26

It it using the enclosure - platform config parameter to push it towards using ALSA or not. However if it not pushed into the ALSA_PLATFORM array, there is no fallback other than telling the mycroft.messagebus about it. This should then be picked up by something else. I believe the enclosure code should listen to the messagebus and do the volume stuff as stated here;
https://github.com/MycroftAI/skill-volume/blob/19.08/__init__.py#L132

The strange thing is, there aren't many enclosures at the moment. You have the mark-1 enclosure, but that one is forced to use ALSA here in the skill. There was no picroft enclosure, although a dialog has been started about it and a initial enclosure has been created with two simple controls for shut down and reboot;
https://github.com/MycroftAI/enclosure-picroft/blob/09488ffa30872b032a4e29cb5ef5355ef1d46400/home/pi/enclosure/PicroftEnclosure.py

But again nothing about the volume and again, it is being pushed into using ALSA within the skill.

The mark-2 has its own enclosure code I believe, however volume control of it is being handled by a skill instead of the enclosure code;
https://github.com/MycroftAI/skill-mark-2-pi/blob/master/__init__.py#L185

I don't know why volume for the mark-2 is handled by directly communication with the I2S bus instead of using ALSA or PulseAudio. Probably because volume control via PulseAudio is not supported.

My idea / opinion

I strongly believe this volume skill should support both ALSA and PulseAudio.
How this could be done in a sane matter is a bit unclear though;

  • Create a PULSE_PLATFORM setting and extend the IF, THEN, ELSE structure with pulsectl functions?
  • Look at the "play_wav_cmdline" and "play_mp3_cmdline" parameters and figure it out from there itself?
  • ...??

Background

Perhaps a bit of backgrounud information about how I come to this topic.
For MycroftOS I am setting up the system to ONLY use PulseAudio. This to have better control about the sinks and sources using the UDEV modules and let PulseAudio kook up straight into the kernel without the need of the ALSA userland system.
This is preperation for other plugins such as resampling and/or AEC Webrtc of PulseAudio.
For MycroftOS I have set the enclosure config parameter to "MycroftOS" and with that parameter set, this volume skill was not doing anything anymore.
Patched this skill to include my enclosure tag into the ALSA_PLATFORM string

For now I am forcing ALL ALSA requests to pulseaudio using the alsa-plugins, which works just fine.
https://github.com/j1nx/MycroftOS/blob/develop/buildroot-external/rootfs-overlay/etc/asound.conf

Volume change doesn't work

Hi,

I use mycroft as an assistant on Ubuntu + KDE.
For the last couple of weeks, the volume skill hasn't been working for me.
It responds to me and apparently works fine ( there are no logged errors ), the volume of my computer isn't actually changing.

Setting volume to out of range integer makes Intent fail

>> Volume set to 10
 set volume to 12
 >> I'm not sure I understood you

Object deviation description

The expected behaviour if the user sets the volume to an out of bounds integer (ie, 12 in this case) is for the Skill to detect that the number is out of bounds, set the volume to the closest in-bound integer (ie 10) and then notify the user. The actual behaviour observed is that an out of bounds integer causes the Intent to fail.

Wait, why is 10 working? shrug I don't have time to dig into this right now, flagging as #hacktoberfest.

Root cause thoughts

The regex defined at https://github.com/MycroftAI/skill-volume/blob/18.08/regex/en-us/volume.amount.rx
is
(?P<Level>\d+)
this matches integer values 0-9, so 10 and above is out of bounds.

A little bit of regex work would make this intent more flexible.

Vocab improvements

I had to dig into this repository to figure out how to control the volume except one unit at a time. Here are things I tried before I looked up the right words:

  • Set volume to max
  • Max volume
  • Increase volume to max
  • Increase volume all the way

Some other things that might be good to cover:

  • Turn the volume down
  • Turn the volume up

Disambiguation between intents that "turn {things} up/down"

Consideration needs to be given to how the Volume Skill will interact (or not) with the Common IoT Framework.

Context of the conversation is also an important factor eg

"change screen brightness to 50%"
"turn it up"

This would be interpreted by a human to mean increase the screen brightness above 50%.

Autoset volume

It would be really nice if Mycroft could auto set volume. So if here is much noise the level is high but if it is quiet volume is low.

In my bedroom, when whatching a movie or listen to music there is noise, and mycroft needs to speak loud. But when i am going to bed and maybe my daughter is sleeping in the bed alredy the bedroom is silent. And if i then ask mycroft to turn off light it is anoing if he is replying loudly.

I were thinking that gettig mic level and setting volume acording to that - whith a delay, so it is messured before a spoken command….

Maybe with a high and low setting so he knows what is high and what is low.

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.