otalk / hark

Converts an audio stream to speech events in the browser
571 stars 96 forks source link

Add a getVolume() API to support on-demand volume level #16

Open kashifshamaz21 opened 9 years ago

kashifshamaz21 commented 9 years ago

A good addition to the library could be adding an API like getVolume(), which would return the current volume level. Currently, the library does a poll for the speaking events, as well as the volume. Having a poll for speaking events does make sense, but for volume, user might want to run the volume meter poll on the client side, and just query the volume when needed.

fippo commented 9 years ago

hm... hark is emitting events by design.

if you want to query the volume, you could store the last known volume emitted on the (api) client.

kashifshamaz21 commented 9 years ago

@fippo yes that can be done, but just thought adding such an api would only help. Also, is there a way to know what are the min and max volume levels that can be expected in volume_change event? This is useful to normalize the volume range over a certain smaller number range to draw the volume level indicator.

latentflip commented 8 years ago

At a guess volume events should be between -100 (no volume) and probably 0 (max volume). Kinda depends exactly what the browser puts out, but that should get you pretty close.

ibc commented 7 years ago

At a guess volume events should be between -100 (no volume) and probably 0 (max volume)

This is not true when the mic is muted (I mean, volume 0): #32