feat(voice-input): conditionally check mic permissions based on STT mode
This commit is contained in:
@@ -523,9 +523,18 @@ class VoiceInputService {
|
|||||||
/// Ensures initialization and microphone permission before starting.
|
/// Ensures initialization and microphone permission before starting.
|
||||||
Future<Stream<String>> beginListening() async {
|
Future<Stream<String>> beginListening() async {
|
||||||
await initialize();
|
await initialize();
|
||||||
final hasMic = await checkPermissions();
|
// For on-device STT we preflight the microphone permission so we can
|
||||||
if (!hasMic) {
|
// fail fast with a clear error before starting any recognition.
|
||||||
throw Exception('Microphone permission not granted');
|
//
|
||||||
|
// For server-only STT we skip the preflight check and let the VAD /
|
||||||
|
// recording pipeline request or validate permissions as needed. This
|
||||||
|
// avoids false negatives from the lightweight probe and prevents
|
||||||
|
// blocking server STT when the platform would otherwise allow it.
|
||||||
|
if (!prefersServerOnly) {
|
||||||
|
final hasMic = await checkPermissions();
|
||||||
|
if (!hasMic) {
|
||||||
|
throw Exception('Microphone permission not granted');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return await startListening();
|
return await startListening();
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user