feat(voice): add VoiceNotifier with recording, silence detection, and streaming TTS
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
import 'package:fabled_app/data/api/voice_api.dart';
|
||||
import 'package:fabled_app/providers/voice_provider.dart';
|
||||
import 'package:fabled_app/data/models/knowledge_item.dart';
|
||||
import 'package:fabled_app/data/models/note.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
@@ -98,4 +99,51 @@ void main() {
|
||||
expect(status.fullyAvailable, isFalse);
|
||||
});
|
||||
});
|
||||
|
||||
group('VoiceNotifier sentence extraction', () {
|
||||
test('extracts complete sentences at full stops', () {
|
||||
final result = extractSentences('Hello world. How are you? I am fine!');
|
||||
expect(result.sentences,
|
||||
equals(['Hello world.', 'How are you?', 'I am fine!']));
|
||||
expect(result.remainder, equals(''));
|
||||
});
|
||||
|
||||
test('leaves incomplete fragment in remainder', () {
|
||||
final result = extractSentences('Hello world. Incomplete');
|
||||
expect(result.sentences, equals(['Hello world.']));
|
||||
expect(result.remainder, equals('Incomplete'));
|
||||
});
|
||||
|
||||
test('returns empty sentences and full text when no boundary', () {
|
||||
final result = extractSentences('No boundary here');
|
||||
expect(result.sentences, isEmpty);
|
||||
expect(result.remainder, equals('No boundary here'));
|
||||
});
|
||||
});
|
||||
|
||||
group('VoiceNotifier markdown stripping', () {
|
||||
test('strips code fences', () {
|
||||
expect(stripMarkdownForTts('Before\n```dart\ncode\n```\nAfter'),
|
||||
equals('Before After'));
|
||||
});
|
||||
|
||||
test('strips bold and italic markers', () {
|
||||
expect(stripMarkdownForTts('**bold** and *italic*'),
|
||||
equals('bold and italic'));
|
||||
});
|
||||
|
||||
test('strips headers', () {
|
||||
expect(stripMarkdownForTts('## Section title'), equals('Section title'));
|
||||
});
|
||||
|
||||
test('keeps link text, removes URL', () {
|
||||
expect(stripMarkdownForTts('[click here](https://example.com)'),
|
||||
equals('click here'));
|
||||
});
|
||||
|
||||
test('strips list markers', () {
|
||||
expect(stripMarkdownForTts('- item one\n- item two'),
|
||||
equals('item one item two'));
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user