Skip to content

Conversation

@mishig25
Copy link
Collaborator

@mishig25 mishig25 commented Apr 27, 2022

Add realtime capability to ASR widget

(attempt number 3 😊)

asrdemo.mov

Testing:
wav2vec2-base-960h-english 🇬🇧
wav2vec2-large-xlsr-53-french 🇫🇷
wav2vec2-large-xlsr-mongolian 🇲🇳

Screenshots

initial state success state
Screenshot 2022-01-16 at 17 09 48 Screenshot 2022-01-16 at 17 09 36
token error mic access error
Screenshot 2022-01-16 at 17 10 04 Screenshot 2022-01-16 at 17 10 34
warning: mic input is empty warning: realtime asr output is empty
Screenshot 2022-01-16 at 17 11 08 Screenshot 2022-01-16 at 17 11 32

@mishig25 mishig25 changed the title Realtime_asr Realtime ASR widget Apr 27, 2022
@@ -0,0 +1,38 @@
class AudioDataExtractor extends AudioWorkletProcessor {
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Pierrci regarding this comment, i'm using js rather than ts because microsoft/TypeScript#28308

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've added @types/audioworklet and the following issues I'm facing are:

  1. when it becomes js/static/audioProcessor.ts, it does not get transpiled to js (looking into why, possible error in adapter-static)
  2. to solve number 1, I've moved js/static/audioProcessor.ts -> js/src/lib/components/InferenceWidget/shared/WidgetRealtimeRecorder/audioProcessor.ts. In this case, I'm getting error ReferenceError: AudioWorkletProcessor is not defined (probably due to SSR)
  3. to solve number 2, I've put the entire context of js/static/audioProcessor.js inside WidgetRealtimeRecorder.svelte onMount function. Still got ReferenceError: AudioWorkletProcessor is not defined inside the browser log.

I might be missing something here. Please let me know if you have any ideas

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes ok, this is 💩

The ReferenceError you were getting was probably because you're were trying to import the audio processor outside of the audioWorklet.addModule fn (AudioWorkletProcessor is only available inside the AudioWorkletGlobalScope)

When audioProcessor.ts is moved in the /shared dir, using imports as URL works correctly w/ the static adapter, but it doesn't work in moon-landing (obviously).

So I think we can keep it in /static (and as .js), and for it to work in moon-landing we will need to add an additional express static handler pointing to this file (which I'm not a fan of, but I don't see any other alternative?)

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, indeed, we do need that /static handler on moon-landing

@mishig25 mishig25 marked this pull request as ready for review April 27, 2022 09:42
Copy link
Member

@Pierrci Pierrci left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Works well! 👍

@mishig25
Copy link
Collaborator Author

mishig25 commented May 6, 2022

@gary149 Hiding the other btns of AutomaticSpeechRecognitionWidget when realtime asr is live

Testing:
wav2vec2-base-960h-english 🇬🇧
wav2vec2-large-xlsr-53-french 🇫🇷
wav2vec2-large-xlsr-mongolian 🇲🇳

Screenshot 2022-05-06 at 09 36 32

Screenshot 2022-05-06 at 09 33 59

@osanseviero
Copy link
Contributor

Is there a netlify link I can try out? https://app.netlify.com/sites/huggingface-widgets/deploys/6274de11534f4a451af9c3ac does not seem to work 😢

@mishig25
Copy link
Collaborator Author

mishig25 commented May 6, 2022

@mishig25 mishig25 merged commit 949f8d3 into main May 10, 2022
@mishig25 mishig25 deleted the realtime_asr branch May 10, 2022 11:54
@julien-c
Copy link
Member

this is cool but it looks like it was a LOT of work, let's make sure we maximize the impact by having as many people as possible use it

Any idea on how to best promote this?

@mishig25
Copy link
Collaborator Author

cc: @patrickvonplaten @osanseviero

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants