Open kuberanb opened 5 months ago
EDIT
The problem its because of emulator. In real device worked fine. Good luck with your solution
@ulisseshen final speechService = await vosk.initSpeechService(recognizer); speechService.onPartial().forEach((partial) => print(partial)); speechService.onResult().forEach((result) => print(result)); await speechService.start(); i used this code and now it worked
`import 'dart:developer'; import 'dart:io'; import 'dart:typed_data'; import 'package:flutter/services.dart'; import 'package:vosk_flutter/vosk_flutter.dart';
class VoskTranscriber { late VoskFlutterPlugin _vosk; Recognizer? _recognizer;
VoskTranscriber() { initializeVosk(); }
Future initializeVosk() async {
Model? _model;
const _sampleRate = 16000;
String? _error;
SpeechService? _speechService;
print("_initializeVosk called");
_vosk = VoskFlutterPlugin.instance();
final modelPath = await ModelLoader()
.loadFromAssets('assets/models/vosk-model-small-en-us-0.15.zip')
.then(
(modelPath) => _vosk.createModel(modelPath)) // create model object
.then((model) => model = model)
.then(() => _vosk.createRecognizer(
model: _model!, sampleRate: _sampleRate)) // create recognizer
.then((value) => _recognizer = value)
.then((recognizer) {
if (Platform.isAndroid) {
_vosk
.initSpeechService(_recognizer!) // init speech service
.then((speechService) => _speechService = speechService)
.catchError((e) => _error = e.toString());
print("sampleRate : ${_sampleRate}");
}
}).catchError((e) {
_error = e.toString();
return null;
});
}
Future transcribeAudio(Uint8List audioBytes) async {
print("transcribeAudio function called");
List results = [];
int chunkSize = 8192;
int pos = 0;
} } `
log
og] partial result in vosk : { "partial" : "" } [log] complete result in vosk : { "text" : "" } 15 [log] partial result in vosk : { "partial" : "" } I/flutter (10378): transcribedText : { I/flutter (10378): "partial" : "" I/flutter (10378): } { I/flutter (10378): "partial" : "" I/flutter (10378): } {