biemster / gasr

Google Chrome SODA Offline Speech Recognition command line client
https://hackaday.io/project/164399-android-offline-speech-recognition-natively-on-pc
150 stars 18 forks source link

Exiting due to stream cancellation / Acoustic ep reader thread cancelled #11

Closed easrng closed 2 years ago

easrng commented 2 years ago

I managed to get the API key by debugging Chrome and putting a breakpoint on the soda creation call (it starts with ce04 and ends with b6cb, right?), are there other binary modifications needed?

Here's the output I get from running ecasound -f:16,1,16000 -i alsa -o:stdout 2>/dev/null | ./gasr.py:

WARNING: Logging before InitGoogle() is written to STDERR
W0000 00:00:1656193072.176636   97762 soda_async_impl.cc:334] Creating soda_impl.
W0000 00:00:1656193072.176677   97762 soda_async_impl.cc:336] Created with thread priority 0
W0000 00:00:1656193072.237460   97762 terse_processor.cc:342] TISID disabled.
W0000 00:00:1656193072.246917   97786 portable_intended_query_stream.cc:236] Exiting due to stream cancellation.
W0000 00:00:1656193072.247448   97762 decoder_endpointer_stream.cc:68] Acoustic ep reader thread cancelled.
W0000 00:00:1656193072.247728   97762 soda_async_impl.cc:561] SODA session starting (require_hotword:0, hotword_timeout_in_millis:0, trigger_type:TRIGGER_TYPE_UNSPECIFIED, hybrid_asr_config.mode:MODE_DEFAULT)
W0000 00:00:1656193072.340946   97768 soda_async_impl.cc:1327] SODA received first mic audio buffer, size in bytes: 640, format: 1, channels: 1, : sample rate: 16000
W0000 00:00:1656193072.868117   97768 soda_async_impl.cc:1046] Not receiving any loopback audio in 500ms. Last audio received time: 0, Current time in us: 1656193072868116
W0000 00:00:1656193073.874142   97794 portable_intended_query_stream.cc:236] Exiting due to stream cancellation.
W0000 00:00:1656193073.876098   97768 decoder_endpointer_stream.cc:68] Acoustic ep reader thread cancelled.
W0000 00:00:1656193074.787109   97813 portable_intended_query_stream.cc:236] Exiting due to stream cancellation.
W0000 00:00:1656193074.788863   97768 decoder_endpointer_stream.cc:68] Acoustic ep reader thread cancelled.
W0000 00:00:1656193075.518735   97834 portable_intended_query_stream.cc:236] Exiting due to stream cancellation.
W0000 00:00:1656193075.520601   97768 decoder_endpointer_stream.cc:68] Acoustic ep reader thread cancelled.
W0000 00:00:1656193076.429067   97844 portable_intended_query_stream.cc:236] Exiting due to stream cancellation.
W0000 00:00:1656193076.430529   97768 decoder_endpointer_stream.cc:68] Acoustic ep reader thread cancelled.
W0000 00:00:1656193077.342094   97864 portable_intended_query_stream.cc:236] Exiting due to stream cancellation.
W0000 00:00:1656193077.343921   97768 decoder_endpointer_stream.cc:68] Acoustic ep reader thread cancelled.
W0000 00:00:1656193078.067318   97874 portable_intended_query_stream.cc:236] Exiting due to stream cancellation.
W0000 00:00:1656193078.068824   97768 decoder_endpointer_stream.cc:68] Acoustic ep reader thread cancelled.
^CW0000 00:00:1656193078.464858   97768 soda_async_impl.cc:945] SODA stopped processing audio, mics audio processed in millis: 6140, loopback audio processed in millis: 0
W0000 00:00:1656193078.466584   97891 portable_intended_query_stream.cc:236] Exiting due to stream cancellation.
W0000 00:00:1656193078.467816   97768 decoder_endpointer_stream.cc:68] Acoustic ep reader thread cancelled.
W0000 00:00:1656193078.468818   97768 soda_async_impl.cc:1000] SODA session stopped due to: STOP_CALLED
W0000 00:00:1656193078.506239   97762 soda_async_impl.cc:1076] Deleting soda_impl
biemster commented 2 years ago

I never figured out the API key, you should just skip all the checks (used to be 3, now there are 4 i think) using a NOP sled or similar. And don't forget to init the variable that will hold the result of the checks to true instead of false.

easrng commented 2 years ago

Alright, got it working!!! NOPing out the checks was enough, you don't need to change a variable anymore. Also, wow ghidra is slowwwwwww.

easrng commented 2 years ago

Okay, you only need to set the variable if you don't have the API key.

brookhong commented 2 years ago

@easrng could you please share how you managed to get the API key?

biemster commented 2 years ago

There is a function google_apis::GetSodaAPIKey() included from google_apis/google_api_keys.h on which you could set a breakpoint if you run chrome in a debugger, for starters. @brookhong If you need this to get soda working I would highly recommend the patch-the-lib route though, since there are other checks besides this one in place. Omitting the other checks basically gives you the omit api key solution for free.

easrng commented 2 years ago

@easrng could you please share how you managed to get the API key?

debugged chrome and put a breakpoint where it was setting up libsoda