esphome / home-assistant-voice-pe

Home Assistant Voice PE
Other
72 stars 10 forks source link

Add temporary sounds #101

Closed jlpouffier closed 1 month ago

jlpouffier commented 1 month ago

Add temporary sounds to the VoiceKit.

All sounds are played using a single script now

script:
  - id: play_sound
    parameters:
      priority: bool
      sound_file: "media_player::MediaFile*"
    then:
      - lambda: |-
          if (priority) {
            id(nabu_media_player)
              ->make_call()
              .set_command(media_player::MediaPlayerCommand::MEDIA_PLAYER_COMMAND_STOP)
              .set_announcement(true)
              .perform();
          }
          if ( (id(nabu_media_player).state != media_player::MediaPlayerState::MEDIA_PLAYER_STATE_ANNOUNCING ) || priority) {
            id(nabu_media_player)
              ->make_call()
              .set_announcement(true)
              .set_local_media_file(sound_file)
              .perform();
          }

The script has a priority flag that changes the behavior of how the sound is played.

Almost every small interaction with buttons is set with priority false - This is because the sounds are quite short and because the longest announcements we can have on the device is the TTS back. I do not want to ditch it if the user plays with the mute switch or the button during a TTS playback.

NOTE: We are waiting for professionally designed sounds.

This PR contains dummy sounds found online just to have all the framework ready. Once the sounds are designed, it will be a matter of replacing some files

NOTE: Some sound files are mp3, some are FLAC.

This is normal. FLAC takes more space but is faster to decode MP3 takes less space but is slower to decode.

I picked FLAC for all small interactions (Button presses and mute flip etc etc) I picked MP3 for all longer less frequent sounds (Factory reset, Connection and the easter eggs)

github-actions[bot] commented 1 month ago

Firmware built successfully! :tada:

Download and extract the firmware to install with https://web.esphome.io

Make sure to choose esphome-voice-kit-esp32s3/esphome-voice-kit-esp32s3.factory.bin.