Skip to content

Commit

Permalink
fix: use direct js access #242
Browse files Browse the repository at this point in the history
  • Loading branch information
sowens-csd committed Dec 5, 2021
1 parent ef92253 commit 0a069ab
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions speech_to_text/lib/speech_to_text_web.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import 'dart:async';
import 'dart:convert';
import 'dart:html' as html;
import 'dart:js_util' as js_util;

import 'package:flutter_web_plugins/flutter_web_plugins.dart';
import 'package:speech_to_text/speech_recognition_error.dart';
Expand Down Expand Up @@ -203,10 +204,13 @@ class SpeechToTextPlugin extends SpeechToTextPlatform {
continue;
}
for (var altIndex = 0; altIndex < recognitionResult.length!; ++altIndex) {
var alt = recognitionResult.item(altIndex);
if (null != alt.transcript && null != alt.confidence) {
recogResults.add(SpeechRecognitionWords(
alt.transcript!, alt.confidence!.toDouble()));
var alt = js_util.callMethod(recognitionResult, 'item', [altIndex]);
if (null == alt) continue;
String? transcript = js_util.getProperty(alt, 'transcript');
num? confidence = js_util.getProperty(alt, 'confidence');
if (null != transcript && null != confidence) {
recogResults
.add(SpeechRecognitionWords(transcript, confidence.toDouble()));
}
}
}
Expand Down

0 comments on commit 0a069ab

Please sign in to comment.