add voice uses to analytics popups

This commit is contained in:
ggurdin 2025-06-11 14:43:48 -04:00
parent 1f5c722bcd
commit 77c6e24863
No known key found for this signature in database
GPG key ID: A01CB41737CBB478
4 changed files with 94 additions and 72 deletions

View file

@ -5014,5 +5014,6 @@
"getStartedFriendsButton": "Invite a friend",
"groupChat": "Group Chat",
"directMessage": "Direct Message",
"newDirectMessage": "New direct message"
"newDirectMessage": "New direct message",
"speakingExercisesTooltip": "Speaking practice"
}

View file

@ -7,7 +7,7 @@ import 'package:fluffychat/l10n/l10n.dart';
enum LearningSkillsEnum {
writing(isVisible: true, icon: Symbols.edit_square),
reading(isVisible: true, icon: Symbols.two_pager),
speaking(isVisible: false),
speaking(isVisible: true, icon: Icons.mic_outlined),
hearing(isVisible: true, icon: Icons.volume_up),
other(isVisible: false);
@ -27,6 +27,8 @@ enum LearningSkillsEnum {
return L10n.of(context).readingExercisesTooltip;
case LearningSkillsEnum.hearing:
return L10n.of(context).listeningExercisesTooltip;
case LearningSkillsEnum.speaking:
return L10n.of(context).speakingExercisesTooltip;
default:
return "";
}

View file

@ -245,6 +245,7 @@ class SpeechToTextModel {
);
for (final sstToken in transcript.sttTokens) {
final token = sstToken.token;
if (!token.lemma.saveVocab) continue;
constructs.addAll(
token.allUses(
ConstructUseTypeEnum.pvm,

View file

@ -142,6 +142,86 @@ class OverlayMessage extends StatelessWidget {
final showSpeechTranslation = overlayController.showSpeechTranslation &&
overlayController.speechTranslation != null;
final transcription = showTranscription
? Container(
width: messageWidth,
constraints: const BoxConstraints(
maxHeight: AppConfig.audioTranscriptionMaxHeight,
),
child: Padding(
padding: const EdgeInsets.all(12.0),
child: overlayController.transcriptionError != null
? Row(
mainAxisSize: MainAxisSize.min,
children: [
Icon(
Icons.error_outline,
color: Theme.of(context).colorScheme.error,
),
const SizedBox(width: 8),
Text(
L10n.of(context).oopsSomethingWentWrong,
style: AppConfig.messageTextStyle(
event,
textColor,
).copyWith(fontStyle: FontStyle.italic),
),
],
)
: overlayController.transcription != null
? SingleChildScrollView(
child: Text(
overlayController.transcription!.transcript.text,
style: AppConfig.messageTextStyle(
event,
textColor,
).copyWith(
fontStyle: FontStyle.italic,
),
),
)
: Row(
mainAxisSize: MainAxisSize.min,
children: [
CircularProgressIndicator.adaptive(
backgroundColor: textColor,
),
],
),
),
)
: const SizedBox();
final translation = showTranslation || showSpeechTranslation
? Container(
width: messageWidth,
constraints: const BoxConstraints(
maxHeight: AppConfig.audioTranscriptionMaxHeight,
),
child: Padding(
padding: const EdgeInsets.fromLTRB(
12.0,
20.0,
12.0,
12.0,
),
child: SingleChildScrollView(
child: Text(
showTranslation
? overlayController.translation!
: overlayController.speechTranslation!,
style: AppConfig.messageTextStyle(
event,
textColor,
).copyWith(
fontStyle: FontStyle.italic,
),
),
),
),
)
: const SizedBox();
final content = Container(
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(
@ -159,6 +239,8 @@ class OverlayMessage extends StatelessWidget {
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
if (readingAssistanceMode == ReadingAssistanceMode.transitionMode)
transcription,
if (event.relationshipType == RelationshipTypes.reply)
FutureBuilder<Event?>(
future: event.getReplyEvent(
@ -257,6 +339,8 @@ class OverlayMessage extends StatelessWidget {
],
),
),
if (readingAssistanceMode == ReadingAssistanceMode.transitionMode)
translation,
],
),
),
@ -273,48 +357,8 @@ class OverlayMessage extends StatelessWidget {
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
if (showTranscription)
Container(
width: messageWidth,
constraints: const BoxConstraints(
maxHeight: AppConfig.audioTranscriptionMaxHeight,
),
child: Padding(
padding: const EdgeInsets.all(12.0),
child: overlayController.transcriptionError != null
? Row(
mainAxisSize: MainAxisSize.min,
children: [
Icon(
Icons.error_outline,
color: Theme.of(context).colorScheme.error,
),
const SizedBox(width: 8),
Text(
L10n.of(context).oopsSomethingWentWrong,
style: AppConfig.messageTextStyle(
event,
textColor,
).copyWith(fontStyle: FontStyle.italic),
),
],
)
: overlayController.transcription != null
? SingleChildScrollView(
child: Text(
overlayController
.transcription!.transcript.text,
style: AppConfig.messageTextStyle(
event,
textColor,
).copyWith(
fontStyle: FontStyle.italic,
),
),
)
: const LinearProgressIndicator(),
),
),
if (readingAssistanceMode != ReadingAssistanceMode.transitionMode)
transcription,
sizeAnimation != null
? AnimatedBuilder(
animation: sizeAnimation!,
@ -327,34 +371,8 @@ class OverlayMessage extends StatelessWidget {
},
)
: content,
if (showTranslation || showSpeechTranslation)
Container(
width: messageWidth,
constraints: const BoxConstraints(
maxHeight: AppConfig.audioTranscriptionMaxHeight,
),
child: Padding(
padding: const EdgeInsets.fromLTRB(
12.0,
20.0,
12.0,
12.0,
),
child: SingleChildScrollView(
child: Text(
showTranslation
? overlayController.translation!
: overlayController.speechTranslation!,
style: AppConfig.messageTextStyle(
event,
textColor,
).copyWith(
fontStyle: FontStyle.italic,
),
),
),
),
),
if (readingAssistanceMode != ReadingAssistanceMode.transitionMode)
translation,
],
),
),