Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -122,4 +122,3 @@ export function recognize({ modelPath, signal }: IKeywordRecognitionOptions): Pr
}

//#endregion

4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@vscode/node-speech",
"version": "1.2.2",
"version": "1.2.3",
"description": "Native bindings for Micrsooft Speech SDK",
"repository": {
"type": "git",
Expand Down
18 changes: 7 additions & 11 deletions src/main.cc
Original file line number Diff line number Diff line change
Expand Up @@ -99,11 +99,6 @@ class TranscriptionWorker : public Napi::AsyncProgressQueueWorker<TranscriptionW
}
auto recognizer = SpeechRecognizer::FromConfig(speechConfig, audioConfig);

auto phraseList = PhraseListGrammar::FromRecognizer(recognizer);
phraseList->AddPhrase("VS Code");
phraseList->AddPhrase("Visual Studio Code");
phraseList->AddPhrase("GitHub");

// Callback: intermediate transcription results
recognizer->Recognizing += [progress](const SpeechRecognitionEventArgs &e)
{
Expand Down Expand Up @@ -431,12 +426,13 @@ class KeywordWorker : public Napi::AsyncProgressQueueWorker<KeywordWorkerCallbac
};

// Starts keyword recognition and wait for end & stopping
// We use std::thread because RecognizeOnceAsync is blocking
// even though it returns a future (this seems to be a bug in
// the SDK)
std::thread([&recognizer, &keywordRecognitionConfig]()
{ recognizer->RecognizeOnceAsync(keywordRecognitionConfig); })
.detach();
// We need to assign the future to a variable to avoid the
// future automatically getting destroyed, which would block
// the thread.
//
// Refs: https://github.com/Azure-Samples/cognitive-services-speech-sdk/issues/2229
// https://stackoverflow.com/questions/23455104/why-is-the-destructor-of-a-future-returned-from-stdasync-blocking
auto recognitionFuture = recognizer->RecognizeOnceAsync(keywordRecognitionConfig);
this->waitingToStop.get();
recognizer->StopRecognitionAsync().get();
}
Expand Down