return timestamps for WebAssembly (#737)
This commit is contained in:
@@ -13,10 +13,14 @@ set(exported_functions
|
||||
CreateOnlineRecognizer
|
||||
CreateOnlineStream
|
||||
DecodeOnlineStream
|
||||
DestroyOfflineStreamResultJson
|
||||
DestroyOnlineRecognizer
|
||||
DestroyOnlineRecognizerResult
|
||||
DestroyOnlineStream
|
||||
DestroyOnlineStreamResultJson
|
||||
GetOfflineStreamResultAsJson
|
||||
GetOnlineStreamResult
|
||||
GetOnlineStreamResultAsJson
|
||||
InputFinished
|
||||
IsEndpoint
|
||||
IsOnlineStreamReady
|
||||
|
||||
@@ -108,7 +108,7 @@ if (navigator.mediaDevices.getUserMedia) {
|
||||
}
|
||||
|
||||
let isEndpoint = recognizer.isEndpoint(recognizer_stream);
|
||||
let result = recognizer.getResult(recognizer_stream);
|
||||
let result = recognizer.getResult(recognizer_stream).text;
|
||||
|
||||
|
||||
if (result.length > 0 && lastResult != result) {
|
||||
|
||||
@@ -661,13 +661,12 @@ class OfflineRecognizer {
|
||||
}
|
||||
|
||||
getResult(stream) {
|
||||
const r = this.Module._GetOfflineStreamResult(stream.handle);
|
||||
const r = this.Module._GetOfflineStreamResultAsJson(stream.handle);
|
||||
const jsonStr = this.Module.UTF8ToString(r);
|
||||
const ans = JSON.parse(jsonStr);
|
||||
this.Module._DestroyOfflineStreamResultJson(r);
|
||||
|
||||
const textPtr = this.Module.getValue(r, 'i8*');
|
||||
const text = this.Module.UTF8ToString(textPtr);
|
||||
|
||||
this.Module._DestroyOfflineRecognizerResult(r);
|
||||
return text;
|
||||
return ans;
|
||||
}
|
||||
};
|
||||
|
||||
@@ -750,11 +749,13 @@ class OnlineRecognizer {
|
||||
}
|
||||
|
||||
getResult(stream) {
|
||||
const r = this.Module._GetOnlineStreamResult(this.handle, stream.handle);
|
||||
const textPtr = this.Module.getValue(r, 'i8*');
|
||||
const text = this.Module.UTF8ToString(textPtr);
|
||||
this.Module._DestroyOnlineRecognizerResult(r);
|
||||
return text;
|
||||
const r =
|
||||
this.Module._GetOnlineStreamResultAsJson(this.handle, stream.handle);
|
||||
const jsonStr = this.Module.UTF8ToString(r);
|
||||
const ans = JSON.parse(jsonStr);
|
||||
this.Module._DestroyOnlineStreamResultJson(r);
|
||||
|
||||
return ans;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user