fix: mic permissions

This commit is contained in:
cogwheel0
2025-08-28 19:48:35 +05:30
parent fe7c7758ba
commit b9f41e0d07
3 changed files with 19 additions and 19 deletions

View File

@@ -250,6 +250,20 @@ class VoiceInputService {
return _textStreamController!.stream;
}
/// Centralized entry point to begin voice recognition.
/// Ensures initialization and microphone permission before starting.
Future<Stream<String>> beginListening() async {
// Ensure service is ready
await initialize();
// Ensure microphone permission (triggers OS prompt if needed)
final hasMic = await checkPermissions();
if (!hasMic) {
throw Exception('Microphone permission not granted');
}
// Start listening and return the transcript stream
return startListening();
}
Future<void> stopListening() async {
await _stopListening();
}