This repository was archived by the owner on Jan 7, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
New .NET/Unity SpeechlyClient audio pipeline #4
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
… AnalyzeFrame function.
… instead of SendAudio.
…eechlyConfig class from constructor.
… Preliminarily added UseCouldSpeechProcessing flag.
…tch processing. a .tsv (tab separated values) file is written if logUtteranceFolder parameter is provided to SpeechlyClient initializer. BeginStream and EndStream calls wrap Start/StopContext to ensure log file is written and to provide a meaningful stream identifies, e.g. an audio file name.
…tartContext task wasn't completed until next update round and resulted in thread freeze.
…veraging new OnStreamStart/Stop and OnContextStart/Stop callbacks.
…both of which implement the IDecoder interface.
…calls are now immediate and any async functionality goes thru websocket (WS) send queue. Introduced WS Send task. More graceful dispmantling of WS. Debug print flag is honoured by decoders.
…d them). Removed async signatures from methods that no longer need them.
…oning of Unity client too well. Added IsReady to check the status of SLU Decoder instead.
…ed some fields and classes internal. Regenerated docs.
langma
reviewed
Apr 13, 2022
speechly-client-net-standard-2.0/Speechly/SLUClient/CloudDecoder.cs
Outdated
Show resolved
Hide resolved
speechly-client-net-standard-2.0/Speechly/SLUClient/SpeechlyClient.cs
Outdated
Show resolved
Hide resolved
speechly-client-net-standard-2.0/Speechly/SLUClient/SpeechlyClient.cs
Outdated
Show resolved
Hide resolved
…ucted from ApiUrl, which is now passed without path.
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
What
New SpeechlyClient audio pipeline
SpeechlyClient.ProcessAudio().inputSampleRatein constructor)HistoryFramesandFrameSamplesin constructor)EnergyTresholdVADin constructor)EnergyTresholdVAD.ControlListening = true)SaveToFolder = "folder"in constructor)UseCloudProcessing = truein constructor)SpeechlyClient now prefers constant audio streams
SpeechlyClient for .NET/Unity is refactored to constantly process audio chunks with
ProcessAudio(float[] inputSamples, start, length). This enables it to automatically control listening using a VAD implementation.StartContext/StopContextcalls can be used to control listening when VAD is not in use. However, it's still recommended to stream audio constantly. Old way of streaming only afterStartContext()works, but is discouraged.Adaptive energy threshold VAD controls hands-free listening
SpeechlyClient comes with optional adaptive energy threshold VAD. It is configured with minimum energy level, a signal-to-noise ratio, minimum activation time and an activation/deactivation treshold (ratio of loud to silent frames). When enough loud frames have been detected, VAD activates and calls StartContext automatically. When enough silent frames have been detected, the VAD deactivates after the sustain time and StopContext is called automatically. The background noise energy gradually adapts when VAD is not active.
History buffer captures the beginning of utterances
SpeechlyClient maintains a configurable ringbuffer of recent audio frames. The size of the history is determined by
historyFrames, each containingframeSamples. History is sent upon StartContext to capture the start of utterance which especially important with VAD, which activates with a constant delay.All SpeechlyClient features can be dry-run on the command line with
dotnetOnly the microphone implementation (MicToSpeechly.cs) is Unity-specific. SpeechlyClient features can be run with prerecorded audio on the command line with little setup. Some command line example setups can tried in
speechly-client-net-standard-2.0/folder:dotnet run testprocesses an example file, sends to Speechly cloud SLU and prints the received results in console.dotnet run vadprocesses an example file, sends the utterances audio to files intemp/folder as 16 bit raw and creates an utterance timestamp.tsv(tab-separated values) for each audio file processed.dotnet run vad myaudiofiles/*.rawprocesses a set of files with VAD.New functions and callbacks
StartStreamshould be called at start of a continuous audio stream. It resets the stream sample counters and history. For backwards compability, ProcessAudio and StartContext ensure it's been called.StopStreamshould be called at the end of a continuous audio stream.OnStreamStartis triggered upon a call to StartStreamOnStreamStopis triggered upon a call to StopStreamOnContextStartis triggered upon a call to StartContext. This can be used to track VAD activation.OnContextStopis triggered upon a call to StopContext. This can be used to track VAD deactivation.dotnet run vadlogging (see previous chapter) is implemented with OnStreamStart, OnStreamStop, OnContextStart and OnContextStop callbacks. These can be also used to log usage metrics.IDecoder interface
CloudDecoder is now an optional module, passed with Initialize(). It implements a IDecoder interface.
Death of ClientState
Removed ClientState that was a 1-to-1 port from browser-client. It did not reflect the internal workings of Unity SpeechlyClient as there are several differences:
await Initialize(new CloudDecoder(...));or check the state of newIsReadyboolean.IsListeningboolean has replaced Starting/Recording/Stopping states both in browser-client and Unity SpeechlyClient.Why
To enable use of all SpeechlyClient features with any audio source, not just the microphone.