tetele / onju-voice-satellite

An ESPHome config for the Onju Voice which makes it a Home Assistant voice satellite
MIT License
73 stars 10 forks source link

Audio quality > 16 kHz #52

Open dreimer1986 opened 2 weeks ago

dreimer1986 commented 2 weeks ago

Checklist

Is your feature request related to a problem? Please describe.

Not really a problem, just muffled audio because of the limit to 16000 Hz. I am very sure I read somewhere about a few reasons for using this limit. I just don't find it anymore.

Describe the solution you'd like

44100 Hz sounds like a nice solution, especially if the media player features are used more often.

Describe alternatives you've considered

Of course I just can use another device as media player, but I want less than more and Onju voice should make my Echo obsolete which is not much left todo for.

Additional context

-

jherby2k commented 2 weeks ago

The issue is that the external/experimental esphome_audio component needed to get esp-idf working with a media player (rather than just a speaker) has some duplex limitations. Specifically, input and output get the same sample rate. There is a resampler, but for whatever reason it doesn't seem to work with the input (mic). So that means the sample rate has to be defined as exactly what the mic can handle. Which is 16kHz.

You can try it yourself! Set the rate to 48000 (lines 147, 160) and the mic will stop working. Different values for input and output won't work. Add the resampler to the input (see lines 181, 171) and the mic will still not work. This is the only setting that currently works.

Hopefully they get the resampler working with input, then you'll be able to set 48000 or whatever.

IMO, the microwakeword version is not ready for use just yet.

dreimer1986 commented 2 weeks ago

In my case I don't even use the microwakeword one as it does not allow me to use my own wakeword. The default one has the same audio "problem" even though there is nothing set up for 16 kHz inside the config. The wakeword one is not ready for use maybe, yes. When I try to use it I get funny errors, like:

adf_pipeline.i2s_audio: [source /data/packages/2ab3d759/esphome/onju-voice-microwakeword.yaml:153]

Unknown value 'audioin', did you mean 'audio_in', 'audio_out'?.

tetele commented 2 weeks ago

@jherby2k do you know if there's an issue we can track regarding this limitation on gnumpi/esphome_audio? I can't seem to find one at first glance.

jherby2k commented 2 weeks ago

There isn't - i added a comment to the existing thread you had there, but it was ignored. I've opened one now: https://github.com/gnumpi/esphome_audio/issues/42

tetele commented 2 weeks ago

Thank you!

dreimer1986 commented 2 weeks ago

Did someone already try it out with the new branch? I am not at home right now and can't test before tomorrow. I am not sure if my audioin renaming to audio_in is really correct, too. (As I said, I use the config without microwakeword right now as my personalized sarcastic catgirl OpenAI is called Luna ^^) I really wonder if I can create a wake word file for microwakeword too...

jherby2k commented 2 weeks ago

I won’t have time until tomorrow.Sent from my iPhoneOn Jun 15, 2024, at 3:18 PM, Daniel Reimer @.***> wrote: Did someone already try it out with the new branch? I am not at home right now and can't test before tomorrow. I am not sure if my audioin renaming to audio_in is really correct, too. (As I said, I use the config without microwakeword right now as my personalized sarcastic catgirl OpenAI is called Luna ^^) I really wonder if I can create a wake word file for microwakeword too...

—Reply to this email directly, view it on GitHub, or unsubscribe.You are receiving this because you were mentioned.Message ID: @.***>

dreimer1986 commented 2 weeks ago

I tried my luck and if there is no fault on my side it does NOT work. I used this config:

substitutions:
  name: onju-voice-e27688
  friendly_name: Onju Voice Satellite e27688
packages:
  tetele.onju_voice_satellite:
    url: https://github.com/dreimer1986/onju-voice-satellite
    file: esphome/onju-voice-microwakeword_1.yaml
    ref: main
    refresh: 0d

esphome:
  name: ${name}
  name_add_mac_suffix: false
  friendly_name: ${friendly_name}
api:
  encryption:
    key: jkgjhkulh
wifi:
  ssid: xxx
  password: xxx
ota:
  platform: esphome

and this package https://github.com/dreimer1986/onju-voice-satellite/blob/main/esphome/onju-voice-microwakeword_1.yaml

and here the log: logs_onju-voice-e27688_run.txt

P.S. Github once more casues MADNESS in line 154 where by magic my "audio-in" written there suddently becomes "audio"+"In" after a bit. Even in here I am UNABLE to type this line as one word in without it being replaced by "audio". O_o I can build a few times and then Github magically changed it back. So take this one with a bit of salt.

dreimer1986 commented 2 weeks ago

Somehow I am too stupid to make things work. According to the report over there it should work now, but something I do is wrong I guess?

dwyschka commented 2 weeks ago

i was testing with gnumpi. please test the following config:

https://github.com/dwyschka/esphome-configs/blob/main/onjou-voice.yml

Adjust it to your needs pls

dreimer1986 commented 2 weeks ago

@dwyschka thx for the help. It was me setting input and output to 16 Bits... Now all is fine again. Music Assistant still is a mess and most of the time does not play as MP3 is not my main source and the only one it sems to like, but the normal media play feature does fine where I can select the right files easily. So... Seems to be way better :D

dwyschka commented 2 weeks ago

enforce lossy mp3 in music assistant on your device, it works better. image

dreimer1986 commented 2 weeks ago

Tried that, but nope. Even then the stream seems to be sort of flac alike: http://192.168.181.42:8098/flow/media_player.onju_voice_e27688_onju_voice_satellite_e27688/87bd58754b47491b800608f96ed48eef.flac?ts=1718660677 it works in browser though, so this is fine, but Onju stays silent. I think that my beta fetish is in the way again ^^ I try to use 2.1.0b6 here.

dreimer1986 commented 1 week ago

Did anyone try to correct the non microwakeword version, too? I tried to (see my fork) but it seems like my copy together tinkering is not working at all.

dwyschka commented 1 week ago

Tried that, but nope. Even then the stream seems to be sort of flac alike: http://192.168.181.42:8098/flow/media_player.onju_voice_e27688_onju_voice_satellite_e27688/87bd58754b47491b800608f96ed48eef.flac?ts=1718660677 it works in browser though, so this is fine, but Onju stays silent. I think that my beta fetish is in the way again ^^ I try to use 2.1.0b6 here.

Which audio provider are you using? i tested with spotify and yt. but, i set the audio quality on the onju to "44100 mhz 24bit". maybe thats the fix for you?

dreimer1986 commented 1 week ago

I tried changing the supported audio output in Music Assistant to 44100 @24Bit, but still have a flac stream inside onju's logs. Do you see a mp3 there?

denisjoshua commented 1 week ago

Subscribe cause I'm interested to make also my 7 ghome mini around my home. Noroc :-)

tbrasser commented 1 day ago

Subscribe cause I'm interested to make also my 7 ghome mini around my home. Noroc :-)

Same