From 326d2b5fbd494cf4aa1a26d5c307a8080230378d Mon Sep 17 00:00:00 2001 From: William Jordan-Cooley Date: Wed, 15 May 2024 10:57:34 -0400 Subject: [PATCH 1/9] adding words per minute to speech to text feedback --- assets/l10n/intl_en.arb | 4 + lib/config/app_config.dart | 2 + .../pangea_message_event.dart | 14 +- lib/pangea/models/speech_to_text_models.dart | 23 ++- .../chat/message_speech_to_text_card.dart | 18 ++- needed-translations.txt | 144 ++++++++++++------ 6 files changed, 137 insertions(+), 68 deletions(-) diff --git a/assets/l10n/intl_en.arb b/assets/l10n/intl_en.arb index 41eeb498d..643ee9a98 100644 --- a/assets/l10n/intl_en.arb +++ b/assets/l10n/intl_en.arb @@ -3945,5 +3945,9 @@ "accuracy": "Accuracy", "points": "Points", "noPaymentInfo": "No payment info necessary!", +<<<<<<< Updated upstream "updatePhoneOS": "You may need to update your device's OS version." +======= + "wordsPerMinute": "Words per minute" +>>>>>>> Stashed changes } \ No newline at end of file diff --git a/lib/config/app_config.dart b/lib/config/app_config.dart index 2b3e74f96..a21a2caad 100644 --- a/lib/config/app_config.dart +++ b/lib/config/app_config.dart @@ -29,6 +29,8 @@ abstract class AppConfig { static const Color primaryColorLight = Color(0xFFDBC9FF); static const Color secondaryColor = Color(0xFF41a2bc); static const Color activeToggleColor = Color(0xFF33D057); + static const Color success = Color(0xFF33D057); + static const Color warning = Color.fromARGB(255, 210, 124, 12); // static String _privacyUrl = // 'https://gitlab.com/famedly/fluffychat/-/blob/main/PRIVACY.md'; static String _privacyUrl = "https://www.pangeachat.com/privacy"; diff --git a/lib/pangea/matrix_event_wrappers/pangea_message_event.dart b/lib/pangea/matrix_event_wrappers/pangea_message_event.dart index 3f2f23616..bea286ba8 100644 --- a/lib/pangea/matrix_event_wrappers/pangea_message_event.dart +++ b/lib/pangea/matrix_event_wrappers/pangea_message_event.dart @@ -296,14 +296,14 @@ class PangeaMessageEvent { return null; } - final SpeechToTextModel? speechToTextLocal = representations - .firstWhereOrNull( - (element) => element.content.speechToText != null, - ) - ?.content - .speechToText; + // final SpeechToTextModel? speechToTextLocal = representations + // .firstWhereOrNull( + // (element) => element.content.speechToText != null, + // ) + // ?.content + // .speechToText; - if (speechToTextLocal != null) return speechToTextLocal; + // if (speechToTextLocal != null) return speechToTextLocal; final matrixFile = await _event.downloadAndDecryptAttachment(); // Pangea# diff --git a/lib/pangea/models/speech_to_text_models.dart b/lib/pangea/models/speech_to_text_models.dart index ad5fd96dd..005d2371f 100644 --- a/lib/pangea/models/speech_to_text_models.dart +++ b/lib/pangea/models/speech_to_text_models.dart @@ -1,11 +1,14 @@ import 'dart:convert'; +import 'package:fluffychat/config/app_config.dart'; import 'package:fluffychat/pangea/enum/audio_encoding_enum.dart'; import 'package:fluffychat/pangea/models/pangea_token_model.dart'; import 'package:flutter/foundation.dart'; import 'package:flutter/material.dart'; import 'package:matrix/matrix.dart'; +const int THRESHOLD_FOR_GREEN = 80; + class SpeechToTextAudioConfigModel { final AudioEncodingEnum encoding; final int sampleRateHertz; @@ -93,13 +96,10 @@ class STTToken { ? Colors.white : Colors.black); } - if (confidence! > 80) { - return const Color.fromARGB(255, 0, 152, 0); + if (confidence! > THRESHOLD_FOR_GREEN) { + return AppConfig.success; } - if (confidence! > 50) { - return const Color.fromARGB(255, 184, 142, 43); - } - return Colors.red; + return AppConfig.warning; } factory STTToken.fromJson(Map json) { @@ -148,6 +148,7 @@ class STTToken { class Transcript { final String text; final int confidence; + final double? wordsPerMinute; final List sttTokens; final String langCode; @@ -156,6 +157,7 @@ class Transcript { required this.confidence, required this.sttTokens, required this.langCode, + required this.wordsPerMinute, }); factory Transcript.fromJson(Map json) => Transcript( @@ -167,6 +169,7 @@ class Transcript { .map((e) => STTToken.fromJson(e)) .toList(), langCode: json['lang_code'], + wordsPerMinute: json['words_per_minute'], ); Map toJson() => { @@ -174,7 +177,15 @@ class Transcript { "confidence": confidence, "stt_tokens": sttTokens.map((e) => e.toJson()).toList(), "lang_code": langCode, + "words_per_minute": wordsPerMinute, }; + + Color color(BuildContext context) { + if (confidence > THRESHOLD_FOR_GREEN) { + return AppConfig.success; + } + return AppConfig.warning; + } } class SpeechToTextResult { diff --git a/lib/pangea/widgets/chat/message_speech_to_text_card.dart b/lib/pangea/widgets/chat/message_speech_to_text_card.dart index c516d4447..6fc02ffe1 100644 --- a/lib/pangea/widgets/chat/message_speech_to_text_card.dart +++ b/lib/pangea/widgets/chat/message_speech_to_text_card.dart @@ -133,6 +133,9 @@ class MessageSpeechToTextCardState extends State { getSpeechToText(); } + String? get wordsPerMinuteString => + speechToTextResponse?.transcript.wordsPerMinute?.toString(); + @override Widget build(BuildContext context) { if (_fetchingTranscription) { @@ -158,11 +161,11 @@ class MessageSpeechToTextCardState extends State { Row( mainAxisAlignment: MainAxisAlignment.spaceEvenly, children: [ - IconNumberWidget( - icon: Icons.abc, - number: (selectedToken == null ? words : 1).toString(), - toolTip: L10n.of(context)!.words, - ), + // IconNumberWidget( + // icon: Icons.abc, + // number: (selectedToken == null ? words : 1).toString(), + // toolTip: L10n.of(context)!.words, + // ), IconNumberWidget( icon: Symbols.target, number: @@ -171,8 +174,9 @@ class MessageSpeechToTextCardState extends State { ), IconNumberWidget( icon: Icons.speed, - number: (selectedToken?.confidence ?? total).toString(), - toolTip: L10n.of(context)!.points, + number: + wordsPerMinuteString != null ? "$wordsPerMinuteString" : "??", + toolTip: L10n.of(context)!.wordsPerMinute, ), ], ), diff --git a/needed-translations.txt b/needed-translations.txt index c93f52d05..74f684f74 100644 --- a/needed-translations.txt +++ b/needed-translations.txt @@ -820,7 +820,8 @@ "score", "accuracy", "points", - "noPaymentInfo" + "noPaymentInfo", + "wordsPerMinute" ], "be": [ @@ -2239,7 +2240,8 @@ "score", "accuracy", "points", - "noPaymentInfo" + "noPaymentInfo", + "wordsPerMinute" ], "bn": [ @@ -3120,7 +3122,8 @@ "score", "accuracy", "points", - "noPaymentInfo" + "noPaymentInfo", + "wordsPerMinute" ], "bo": [ @@ -4001,7 +4004,8 @@ "score", "accuracy", "points", - "noPaymentInfo" + "noPaymentInfo", + "wordsPerMinute" ], "ca": [ @@ -4882,7 +4886,8 @@ "score", "accuracy", "points", - "noPaymentInfo" + "noPaymentInfo", + "wordsPerMinute" ], "cs": [ @@ -5763,7 +5768,8 @@ "score", "accuracy", "points", - "noPaymentInfo" + "noPaymentInfo", + "wordsPerMinute" ], "de": [ @@ -6591,7 +6597,8 @@ "score", "accuracy", "points", - "noPaymentInfo" + "noPaymentInfo", + "wordsPerMinute" ], "el": [ @@ -7472,7 +7479,8 @@ "score", "accuracy", "points", - "noPaymentInfo" + "noPaymentInfo", + "wordsPerMinute" ], "eo": [ @@ -8353,7 +8361,8 @@ "score", "accuracy", "points", - "noPaymentInfo" + "noPaymentInfo", + "wordsPerMinute" ], "es": [ @@ -8382,7 +8391,8 @@ "score", "accuracy", "points", - "noPaymentInfo" + "noPaymentInfo", + "wordsPerMinute" ], "et": [ @@ -9206,7 +9216,8 @@ "score", "accuracy", "points", - "noPaymentInfo" + "noPaymentInfo", + "wordsPerMinute" ], "eu": [ @@ -10030,7 +10041,8 @@ "score", "accuracy", "points", - "noPaymentInfo" + "noPaymentInfo", + "wordsPerMinute" ], "fa": [ @@ -10911,7 +10923,8 @@ "score", "accuracy", "points", - "noPaymentInfo" + "noPaymentInfo", + "wordsPerMinute" ], "fi": [ @@ -11792,7 +11805,8 @@ "score", "accuracy", "points", - "noPaymentInfo" + "noPaymentInfo", + "wordsPerMinute" ], "fr": [ @@ -12673,7 +12687,8 @@ "score", "accuracy", "points", - "noPaymentInfo" + "noPaymentInfo", + "wordsPerMinute" ], "ga": [ @@ -13554,7 +13569,8 @@ "score", "accuracy", "points", - "noPaymentInfo" + "noPaymentInfo", + "wordsPerMinute" ], "gl": [ @@ -14378,7 +14394,8 @@ "score", "accuracy", "points", - "noPaymentInfo" + "noPaymentInfo", + "wordsPerMinute" ], "he": [ @@ -15259,7 +15276,8 @@ "score", "accuracy", "points", - "noPaymentInfo" + "noPaymentInfo", + "wordsPerMinute" ], "hi": [ @@ -16140,7 +16158,8 @@ "score", "accuracy", "points", - "noPaymentInfo" + "noPaymentInfo", + "wordsPerMinute" ], "hr": [ @@ -17008,7 +17027,8 @@ "score", "accuracy", "points", - "noPaymentInfo" + "noPaymentInfo", + "wordsPerMinute" ], "hu": [ @@ -17889,7 +17909,8 @@ "score", "accuracy", "points", - "noPaymentInfo" + "noPaymentInfo", + "wordsPerMinute" ], "ia": [ @@ -19294,7 +19315,8 @@ "score", "accuracy", "points", - "noPaymentInfo" + "noPaymentInfo", + "wordsPerMinute" ], "id": [ @@ -20175,7 +20197,8 @@ "score", "accuracy", "points", - "noPaymentInfo" + "noPaymentInfo", + "wordsPerMinute" ], "ie": [ @@ -21056,7 +21079,8 @@ "score", "accuracy", "points", - "noPaymentInfo" + "noPaymentInfo", + "wordsPerMinute" ], "it": [ @@ -21922,7 +21946,8 @@ "score", "accuracy", "points", - "noPaymentInfo" + "noPaymentInfo", + "wordsPerMinute" ], "ja": [ @@ -22803,7 +22828,8 @@ "score", "accuracy", "points", - "noPaymentInfo" + "noPaymentInfo", + "wordsPerMinute" ], "ko": [ @@ -23684,7 +23710,8 @@ "score", "accuracy", "points", - "noPaymentInfo" + "noPaymentInfo", + "wordsPerMinute" ], "lt": [ @@ -24565,7 +24592,8 @@ "score", "accuracy", "points", - "noPaymentInfo" + "noPaymentInfo", + "wordsPerMinute" ], "lv": [ @@ -25446,7 +25474,8 @@ "score", "accuracy", "points", - "noPaymentInfo" + "noPaymentInfo", + "wordsPerMinute" ], "nb": [ @@ -26327,7 +26356,8 @@ "score", "accuracy", "points", - "noPaymentInfo" + "noPaymentInfo", + "wordsPerMinute" ], "nl": [ @@ -27208,7 +27238,8 @@ "score", "accuracy", "points", - "noPaymentInfo" + "noPaymentInfo", + "wordsPerMinute" ], "pl": [ @@ -28089,7 +28120,8 @@ "score", "accuracy", "points", - "noPaymentInfo" + "noPaymentInfo", + "wordsPerMinute" ], "pt": [ @@ -28970,7 +29002,8 @@ "score", "accuracy", "points", - "noPaymentInfo" + "noPaymentInfo", + "wordsPerMinute" ], "pt_BR": [ @@ -29820,7 +29853,8 @@ "score", "accuracy", "points", - "noPaymentInfo" + "noPaymentInfo", + "wordsPerMinute" ], "pt_PT": [ @@ -30701,7 +30735,8 @@ "score", "accuracy", "points", - "noPaymentInfo" + "noPaymentInfo", + "wordsPerMinute" ], "ro": [ @@ -31582,7 +31617,8 @@ "score", "accuracy", "points", - "noPaymentInfo" + "noPaymentInfo", + "wordsPerMinute" ], "ru": [ @@ -32406,7 +32442,8 @@ "score", "accuracy", "points", - "noPaymentInfo" + "noPaymentInfo", + "wordsPerMinute" ], "sk": [ @@ -33287,7 +33324,8 @@ "score", "accuracy", "points", - "noPaymentInfo" + "noPaymentInfo", + "wordsPerMinute" ], "sl": [ @@ -34168,7 +34206,8 @@ "score", "accuracy", "points", - "noPaymentInfo" + "noPaymentInfo", + "wordsPerMinute" ], "sr": [ @@ -35049,7 +35088,8 @@ "score", "accuracy", "points", - "noPaymentInfo" + "noPaymentInfo", + "wordsPerMinute" ], "sv": [ @@ -35895,7 +35935,8 @@ "score", "accuracy", "points", - "noPaymentInfo" + "noPaymentInfo", + "wordsPerMinute" ], "ta": [ @@ -36776,7 +36817,8 @@ "score", "accuracy", "points", - "noPaymentInfo" + "noPaymentInfo", + "wordsPerMinute" ], "th": [ @@ -37657,7 +37699,8 @@ "score", "accuracy", "points", - "noPaymentInfo" + "noPaymentInfo", + "wordsPerMinute" ], "tr": [ @@ -38523,7 +38566,8 @@ "score", "accuracy", "points", - "noPaymentInfo" + "noPaymentInfo", + "wordsPerMinute" ], "uk": [ @@ -39347,7 +39391,8 @@ "score", "accuracy", "points", - "noPaymentInfo" + "noPaymentInfo", + "wordsPerMinute" ], "vi": [ @@ -40228,7 +40273,8 @@ "score", "accuracy", "points", - "noPaymentInfo" + "noPaymentInfo", + "wordsPerMinute" ], "zh": [ @@ -41052,7 +41098,8 @@ "score", "accuracy", "points", - "noPaymentInfo" + "noPaymentInfo", + "wordsPerMinute" ], "zh_Hant": [ @@ -41933,6 +41980,7 @@ "score", "accuracy", "points", - "noPaymentInfo" + "noPaymentInfo", + "wordsPerMinute" ] } From daaa83b00df2dd2bf57145da105ec14a1733f4a1 Mon Sep 17 00:00:00 2001 From: William Jordan-Cooley Date: Wed, 15 May 2024 11:01:20 -0400 Subject: [PATCH 2/9] fixing two oops --- assets/l10n/intl_en.arb | 5 +---- .../pangea_message_event.dart | 14 +++++++------- 2 files changed, 8 insertions(+), 11 deletions(-) diff --git a/assets/l10n/intl_en.arb b/assets/l10n/intl_en.arb index 643ee9a98..2ea0bc307 100644 --- a/assets/l10n/intl_en.arb +++ b/assets/l10n/intl_en.arb @@ -3945,9 +3945,6 @@ "accuracy": "Accuracy", "points": "Points", "noPaymentInfo": "No payment info necessary!", -<<<<<<< Updated upstream - "updatePhoneOS": "You may need to update your device's OS version." -======= + "updatePhoneOS": "You may need to update your device's OS version.", "wordsPerMinute": "Words per minute" ->>>>>>> Stashed changes } \ No newline at end of file diff --git a/lib/pangea/matrix_event_wrappers/pangea_message_event.dart b/lib/pangea/matrix_event_wrappers/pangea_message_event.dart index bea286ba8..3f2f23616 100644 --- a/lib/pangea/matrix_event_wrappers/pangea_message_event.dart +++ b/lib/pangea/matrix_event_wrappers/pangea_message_event.dart @@ -296,14 +296,14 @@ class PangeaMessageEvent { return null; } - // final SpeechToTextModel? speechToTextLocal = representations - // .firstWhereOrNull( - // (element) => element.content.speechToText != null, - // ) - // ?.content - // .speechToText; + final SpeechToTextModel? speechToTextLocal = representations + .firstWhereOrNull( + (element) => element.content.speechToText != null, + ) + ?.content + .speechToText; - // if (speechToTextLocal != null) return speechToTextLocal; + if (speechToTextLocal != null) return speechToTextLocal; final matrixFile = await _event.downloadAndDecryptAttachment(); // Pangea# From 8f7f9a8a18d3e05747e0d73ed882ffd4d5a9a896 Mon Sep 17 00:00:00 2001 From: ggurdin Date: Wed, 15 May 2024 11:24:56 -0400 Subject: [PATCH 3/9] spanish translations --- assets/l10n/intl_es.arb | 51 +++++++++++++++++++++++++-- needed-translations.txt | 77 +++++++++++++++++++++++++---------------- 2 files changed, 96 insertions(+), 32 deletions(-) diff --git a/assets/l10n/intl_es.arb b/assets/l10n/intl_es.arb index f9f596f16..795a83ef7 100644 --- a/assets/l10n/intl_es.arb +++ b/assets/l10n/intl_es.arb @@ -4587,5 +4587,52 @@ "refresh": "Actualizar", "joinToView": "Únete a esta sala para ver los detalles", "autoPlayTitle": "Reproducción automática de mensajes", - "autoPlayDesc": "Cuando está activado, el audio de texto a voz de los mensajes se reproducirá automáticamente cuando se seleccione." -} \ No newline at end of file + "autoPlayDesc": "Cuando está activado, el audio de texto a voz de los mensajes se reproducirá automáticamente cuando se seleccione.", + "presenceStyle": "Presencia:", + "presencesToggle": "Mostrar mensajes de estado de otros usuarios", + "writeAMessageFlag": "Escribe un mensaje en {l1flag} o {l2flag}...", + "@writeAMessageFlag": { + "type": "text", + "placeholders": { + "l1flag": {}, + "l2flag": {} + } + }, + "youInvitedToBy": "📩 Has sido invitado a través de un enlace a:\n{alias}", + "@youInvitedToBy": { + "placeholders": { + "alias": {} + } + }, + "hidePresences": "¿Ocultar la lista de estados?", + "sendReadReceipts": "Enviar recibos de lectura", + "sendTypingNotificationsDescription": "Los demás participantes en un chat pueden ver cuándo estás escribiendo un nuevo mensaje.", + "sendReadReceiptsDescription": "Los demás participantes en un chat pueden ver cuándo has leído un mensaje.", + "formattedMessages": "Mensajes con formato", + "formattedMessagesDescription": "Mostrar contenido de mensajes enriquecido como texto en negrita utilizando markdown.", + "verifyOtherUser": "🔐 Verificar otro usuario", + "verifyOtherUserDescription": "Si verificas a otro usuario, puedes estar seguro de saber a quién estás escribiendo realmente. 💪\n\nCuando inicies una verificación, tú y el otro usuario veréis una ventana emergente en la aplicación. Allí veréis una serie de emojis o números que tendréis que comparar entre vosotros.\n\nLa mejor forma de hacerlo es quedar o iniciar una videollamada. 👭", + "verifyOtherDevice": "🔐 Verificar otro dispositivo", + "verifyOtherDeviceDescription": "Cuando verificas otro dispositivo, esos dispositivos pueden intercambiar claves, aumentando tu seguridad general. 💪 Cuando inicies una verificación, aparecerá una ventana emergente en la app de ambos dispositivos. Allí verás entonces una serie de emojis o números que tienes que comparar entre sí. Lo mejor es que tengas ambos dispositivos a mano antes de iniciar la verificación. 🤳", + "transparent": "Transparente", + "incomingMessages": "Mensajes entrantes", + "stickers": "Pegatinas", + "commandHint_ignore": "Ignorar el ID de matriz dado", + "commandHint_unignore": "Designorar el ID de matriz dado", + "unreadChatsInApp": "{appname}: {unread} chats no leídos", + "@unreadChatsInApp": { + "type": "text", + "placeholders": { + "appname": {}, + "unread": {} + } + }, + "messageAnalytics": "Análisis de mensajes", + "words": "Palabras", + "score": "Puntuación", + "accuracy": "Precisión", + "points": "Puntos", + "noPaymentInfo": "No se necesitan datos de pago.", + "updatePhoneOS": "Puede que necesites actualizar la versión del sistema operativo de tu dispositivo.", + "wordsPerMinute": "Palabras por minuto" +} diff --git a/needed-translations.txt b/needed-translations.txt index 74f684f74..7cbcc8a05 100644 --- a/needed-translations.txt +++ b/needed-translations.txt @@ -821,6 +821,7 @@ "accuracy", "points", "noPaymentInfo", + "updatePhoneOS", "wordsPerMinute" ], @@ -2241,6 +2242,7 @@ "accuracy", "points", "noPaymentInfo", + "updatePhoneOS", "wordsPerMinute" ], @@ -3123,6 +3125,7 @@ "accuracy", "points", "noPaymentInfo", + "updatePhoneOS", "wordsPerMinute" ], @@ -4005,6 +4008,7 @@ "accuracy", "points", "noPaymentInfo", + "updatePhoneOS", "wordsPerMinute" ], @@ -4887,6 +4891,7 @@ "accuracy", "points", "noPaymentInfo", + "updatePhoneOS", "wordsPerMinute" ], @@ -5769,6 +5774,7 @@ "accuracy", "points", "noPaymentInfo", + "updatePhoneOS", "wordsPerMinute" ], @@ -6598,6 +6604,7 @@ "accuracy", "points", "noPaymentInfo", + "updatePhoneOS", "wordsPerMinute" ], @@ -7480,6 +7487,7 @@ "accuracy", "points", "noPaymentInfo", + "updatePhoneOS", "wordsPerMinute" ], @@ -8362,36 +8370,7 @@ "accuracy", "points", "noPaymentInfo", - "wordsPerMinute" - ], - - "es": [ - "presenceStyle", - "presencesToggle", - "writeAMessageFlag", - "youInvitedToBy", - "hidePresences", - "sendReadReceipts", - "sendTypingNotificationsDescription", - "sendReadReceiptsDescription", - "formattedMessages", - "formattedMessagesDescription", - "verifyOtherUser", - "verifyOtherUserDescription", - "verifyOtherDevice", - "verifyOtherDeviceDescription", - "transparent", - "incomingMessages", - "stickers", - "commandHint_ignore", - "commandHint_unignore", - "unreadChatsInApp", - "messageAnalytics", - "words", - "score", - "accuracy", - "points", - "noPaymentInfo", + "updatePhoneOS", "wordsPerMinute" ], @@ -9217,6 +9196,7 @@ "accuracy", "points", "noPaymentInfo", + "updatePhoneOS", "wordsPerMinute" ], @@ -10042,6 +10022,7 @@ "accuracy", "points", "noPaymentInfo", + "updatePhoneOS", "wordsPerMinute" ], @@ -10924,6 +10905,7 @@ "accuracy", "points", "noPaymentInfo", + "updatePhoneOS", "wordsPerMinute" ], @@ -11806,6 +11788,7 @@ "accuracy", "points", "noPaymentInfo", + "updatePhoneOS", "wordsPerMinute" ], @@ -12688,6 +12671,7 @@ "accuracy", "points", "noPaymentInfo", + "updatePhoneOS", "wordsPerMinute" ], @@ -13570,6 +13554,7 @@ "accuracy", "points", "noPaymentInfo", + "updatePhoneOS", "wordsPerMinute" ], @@ -14395,6 +14380,7 @@ "accuracy", "points", "noPaymentInfo", + "updatePhoneOS", "wordsPerMinute" ], @@ -15277,6 +15263,7 @@ "accuracy", "points", "noPaymentInfo", + "updatePhoneOS", "wordsPerMinute" ], @@ -16159,6 +16146,7 @@ "accuracy", "points", "noPaymentInfo", + "updatePhoneOS", "wordsPerMinute" ], @@ -17028,6 +17016,7 @@ "accuracy", "points", "noPaymentInfo", + "updatePhoneOS", "wordsPerMinute" ], @@ -17910,6 +17899,7 @@ "accuracy", "points", "noPaymentInfo", + "updatePhoneOS", "wordsPerMinute" ], @@ -19316,6 +19306,7 @@ "accuracy", "points", "noPaymentInfo", + "updatePhoneOS", "wordsPerMinute" ], @@ -20198,6 +20189,7 @@ "accuracy", "points", "noPaymentInfo", + "updatePhoneOS", "wordsPerMinute" ], @@ -21080,6 +21072,7 @@ "accuracy", "points", "noPaymentInfo", + "updatePhoneOS", "wordsPerMinute" ], @@ -21947,6 +21940,7 @@ "accuracy", "points", "noPaymentInfo", + "updatePhoneOS", "wordsPerMinute" ], @@ -22829,6 +22823,7 @@ "accuracy", "points", "noPaymentInfo", + "updatePhoneOS", "wordsPerMinute" ], @@ -23711,6 +23706,7 @@ "accuracy", "points", "noPaymentInfo", + "updatePhoneOS", "wordsPerMinute" ], @@ -24593,6 +24589,7 @@ "accuracy", "points", "noPaymentInfo", + "updatePhoneOS", "wordsPerMinute" ], @@ -25475,6 +25472,7 @@ "accuracy", "points", "noPaymentInfo", + "updatePhoneOS", "wordsPerMinute" ], @@ -26357,6 +26355,7 @@ "accuracy", "points", "noPaymentInfo", + "updatePhoneOS", "wordsPerMinute" ], @@ -27239,6 +27238,7 @@ "accuracy", "points", "noPaymentInfo", + "updatePhoneOS", "wordsPerMinute" ], @@ -28121,6 +28121,7 @@ "accuracy", "points", "noPaymentInfo", + "updatePhoneOS", "wordsPerMinute" ], @@ -29003,6 +29004,7 @@ "accuracy", "points", "noPaymentInfo", + "updatePhoneOS", "wordsPerMinute" ], @@ -29854,6 +29856,7 @@ "accuracy", "points", "noPaymentInfo", + "updatePhoneOS", "wordsPerMinute" ], @@ -30736,6 +30739,7 @@ "accuracy", "points", "noPaymentInfo", + "updatePhoneOS", "wordsPerMinute" ], @@ -31618,6 +31622,7 @@ "accuracy", "points", "noPaymentInfo", + "updatePhoneOS", "wordsPerMinute" ], @@ -32443,6 +32448,7 @@ "accuracy", "points", "noPaymentInfo", + "updatePhoneOS", "wordsPerMinute" ], @@ -33325,6 +33331,7 @@ "accuracy", "points", "noPaymentInfo", + "updatePhoneOS", "wordsPerMinute" ], @@ -34207,6 +34214,7 @@ "accuracy", "points", "noPaymentInfo", + "updatePhoneOS", "wordsPerMinute" ], @@ -35089,6 +35097,7 @@ "accuracy", "points", "noPaymentInfo", + "updatePhoneOS", "wordsPerMinute" ], @@ -35936,6 +35945,7 @@ "accuracy", "points", "noPaymentInfo", + "updatePhoneOS", "wordsPerMinute" ], @@ -36818,6 +36828,7 @@ "accuracy", "points", "noPaymentInfo", + "updatePhoneOS", "wordsPerMinute" ], @@ -37700,6 +37711,7 @@ "accuracy", "points", "noPaymentInfo", + "updatePhoneOS", "wordsPerMinute" ], @@ -38567,6 +38579,7 @@ "accuracy", "points", "noPaymentInfo", + "updatePhoneOS", "wordsPerMinute" ], @@ -39392,6 +39405,7 @@ "accuracy", "points", "noPaymentInfo", + "updatePhoneOS", "wordsPerMinute" ], @@ -40274,6 +40288,7 @@ "accuracy", "points", "noPaymentInfo", + "updatePhoneOS", "wordsPerMinute" ], @@ -41099,6 +41114,7 @@ "accuracy", "points", "noPaymentInfo", + "updatePhoneOS", "wordsPerMinute" ], @@ -41981,6 +41997,7 @@ "accuracy", "points", "noPaymentInfo", + "updatePhoneOS", "wordsPerMinute" ] } From 7131fd47a8b693cbac8a38014d2a26b84a930bdb Mon Sep 17 00:00:00 2001 From: ggurdin Date: Wed, 15 May 2024 13:43:21 -0400 Subject: [PATCH 4/9] fix for speech to text matrix event --- .../speech_to_text_controller.dart | 27 ++++++++++--------- lib/pangea/models/pangea_token_model.dart | 2 +- lib/pangea/models/speech_to_text_models.dart | 2 +- 3 files changed, 17 insertions(+), 14 deletions(-) diff --git a/lib/pangea/controllers/speech_to_text_controller.dart b/lib/pangea/controllers/speech_to_text_controller.dart index 6b302b101..8b61da79e 100644 --- a/lib/pangea/controllers/speech_to_text_controller.dart +++ b/lib/pangea/controllers/speech_to_text_controller.dart @@ -74,18 +74,21 @@ class SpeechToTextController { } debugPrint('Saving transcript as matrix event'); - requestModel.audioEvent?.room.sendPangeaEvent( - content: PangeaRepresentation( - langCode: response.langCode, - text: response.transcript.text, - originalSent: false, - originalWritten: false, - speechToText: response, - ).toJson(), - parentEventId: requestModel.audioEvent!.eventId, - type: PangeaEventTypes.representation, - ); - debugPrint('Transcript saved as matrix event'); + requestModel.audioEvent?.room + .sendPangeaEvent( + content: PangeaRepresentation( + langCode: response.langCode, + text: response.transcript.text, + originalSent: false, + originalWritten: false, + speechToText: response, + ).toJson(), + parentEventId: requestModel.audioEvent!.eventId, + type: PangeaEventTypes.representation, + ) + .then( + (_) => debugPrint('Transcript saved as matrix event'), + ); return Future.value(null); } diff --git a/lib/pangea/models/pangea_token_model.dart b/lib/pangea/models/pangea_token_model.dart index 19eaba750..a671256ab 100644 --- a/lib/pangea/models/pangea_token_model.dart +++ b/lib/pangea/models/pangea_token_model.dart @@ -60,7 +60,7 @@ class PangeaToken { static const String _lemmaKey = ModelKey.lemma; Map toJson() => { - _textKey: text, + _textKey: text.toJson(), _hasInfoKey: hasInfo, _lemmaKey: lemmas.map((e) => e.toJson()).toList(), }; diff --git a/lib/pangea/models/speech_to_text_models.dart b/lib/pangea/models/speech_to_text_models.dart index 005d2371f..7d21fd718 100644 --- a/lib/pangea/models/speech_to_text_models.dart +++ b/lib/pangea/models/speech_to_text_models.dart @@ -117,7 +117,7 @@ class STTToken { } Map toJson() => { - "token": token, + "token": token.toJson(), "start_time": startTime?.inMilliseconds, "end_time": endTime?.inMilliseconds, "confidence": confidence, From 36c1eaaf47540c467bdeab04a5b05a0828bef42c Mon Sep 17 00:00:00 2001 From: Kelrap <99418823+Kelrap@users.noreply.github.com> Date: Wed, 15 May 2024 13:50:35 -0400 Subject: [PATCH 5/9] Update intl_en.arb Change Settings/Learning Settings to Main Menu/My Learning Settings --- assets/l10n/intl_en.arb | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/assets/l10n/intl_en.arb b/assets/l10n/intl_en.arb index 2ea0bc307..ec8261740 100644 --- a/assets/l10n/intl_en.arb +++ b/assets/l10n/intl_en.arb @@ -2504,7 +2504,7 @@ "type": "text", "placeholders": {} }, - "interactiveTranslatorAllowedDesc": "Students can choose whether to use translation assistance in space group chats in Settings > Learning Settings.", + "interactiveTranslatorAllowedDesc": "Students can choose whether to use translation assistance in space group chats in Main Menu > My Learning Settings.", "@interactiveTranslatorAllowedDesc": { "type": "text", "placeholders": {} @@ -2984,9 +2984,9 @@ "errorDisableLanguageAssistanceClassDesc": "Translation assistance and grammar assistance are turned off for the space that this chat is in.", "itIsDisabled": "Interactive Translation is disabled", "igcIsDisabled": "Interactive Grammar Checking is disabled", - "goToLearningSettings": "Go to Learning Settings", + "goToLearningSettings": "Go to My Learning Settings", "error405Title": "Languages not set", - "error405Desc": "Please set your languages in Settings > Learning Settings", + "error405Desc": "Please set your languages in Main Menu > My Learning Settings.", "loginOrSignup": "Sign in with", "@loginOrSignup": { "type": "text", @@ -3049,7 +3049,7 @@ "type": "text", "placeholders": {} }, - "learningSettings": "Learning Settings", + "learningSettings": "My Learning Settings", "classNameRequired": "Please enter a space name", "@classNameRequired": { "type": "text", @@ -3947,4 +3947,4 @@ "noPaymentInfo": "No payment info necessary!", "updatePhoneOS": "You may need to update your device's OS version.", "wordsPerMinute": "Words per minute" -} \ No newline at end of file +} From cd0545058129e16e8e46971721b1cdd68f079a93 Mon Sep 17 00:00:00 2001 From: Kelrap <99418823+Kelrap@users.noreply.github.com> Date: Wed, 15 May 2024 13:52:55 -0400 Subject: [PATCH 6/9] Removed the Learning Settings button --- lib/pages/settings/settings_view.dart | 8 -------- 1 file changed, 8 deletions(-) diff --git a/lib/pages/settings/settings_view.dart b/lib/pages/settings/settings_view.dart index 36766ea65..cc52f0ef0 100644 --- a/lib/pages/settings/settings_view.dart +++ b/lib/pages/settings/settings_view.dart @@ -181,14 +181,6 @@ class SettingsView extends StatelessWidget { trailing: const Icon(Icons.chevron_right_outlined), ), // #Pangea - ListTile( - leading: const Icon(Icons.account_circle_outlined), - title: Text(L10n.of(context)!.learningSettings), - onTap: () => context.go('/rooms/settings/learning'), - trailing: const Icon( - Icons.chevron_right_outlined, - ), - ), ListTile( leading: const Icon(Icons.account_circle_outlined), title: Text(L10n.of(context)!.subscriptionManagement), From bc47e84de26576ecff39e62f32e063fac11cbfdd Mon Sep 17 00:00:00 2001 From: ggurdin Date: Wed, 15 May 2024 13:58:57 -0400 Subject: [PATCH 7/9] uncommented error handling so warning message shows on card, instead of loading circle --- .../chat/message_speech_to_text_card.dart | 44 ++++++++++--------- 1 file changed, 24 insertions(+), 20 deletions(-) diff --git a/lib/pangea/widgets/chat/message_speech_to_text_card.dart b/lib/pangea/widgets/chat/message_speech_to_text_card.dart index 6fc02ffe1..bc2cf3327 100644 --- a/lib/pangea/widgets/chat/message_speech_to_text_card.dart +++ b/lib/pangea/widgets/chat/message_speech_to_text_card.dart @@ -1,9 +1,13 @@ +import 'dart:developer'; + import 'package:fluffychat/pangea/matrix_event_wrappers/pangea_message_event.dart'; import 'package:fluffychat/pangea/models/speech_to_text_models.dart'; +import 'package:fluffychat/pangea/utils/error_handler.dart'; import 'package:fluffychat/pangea/widgets/chat/toolbar_content_loading_indicator.dart'; import 'package:fluffychat/pangea/widgets/common/icon_number_widget.dart'; import 'package:fluffychat/pangea/widgets/igc/card_error_widget.dart'; import 'package:fluffychat/widgets/matrix.dart'; +import 'package:flutter/foundation.dart'; import 'package:flutter/gestures.dart'; import 'package:flutter/material.dart'; import 'package:flutter_gen/gen_l10n/l10n.dart'; @@ -41,27 +45,27 @@ class MessageSpeechToTextCardState extends State { // look for transcription in message event // if not found, call API to transcribe audio Future getSpeechToText() async { - // try { - if (l1Code == null || l2Code == null) { - throw Exception('Language selection not found'); - } - speechToTextResponse ??= - await widget.messageEvent.getSpeechToText(l1Code!, l2Code!); + try { + if (l1Code == null || l2Code == null) { + throw Exception('Language selection not found'); + } + speechToTextResponse ??= + await widget.messageEvent.getSpeechToText(l1Code!, l2Code!); - debugPrint( - 'Speech to text transcript: ${speechToTextResponse?.transcript.text}', - ); - // } catch (e, s) { - // debugger(when: kDebugMode); - // error = e; - // ErrorHandler.logError( - // e: e, - // s: s, - // data: widget.messageEvent.event.content, - // ); - // } finally { - setState(() => _fetchingTranscription = false); - // } + debugPrint( + 'Speech to text transcript: ${speechToTextResponse?.transcript.text}', + ); + } catch (e, s) { + debugger(when: kDebugMode); + error = e; + ErrorHandler.logError( + e: e, + s: s, + data: widget.messageEvent.event.content, + ); + } finally { + setState(() => _fetchingTranscription = false); + } } TextSpan _buildTranscriptText(BuildContext context) { From 09e4feb6c22b42e45f3ce00103ecfde96413b6f3 Mon Sep 17 00:00:00 2001 From: Kelrap <99418823+Kelrap@users.noreply.github.com> Date: Wed, 15 May 2024 14:01:17 -0400 Subject: [PATCH 8/9] Added My Learning Settings button to main menu --- lib/pages/chat_list/client_chooser_button.dart | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/lib/pages/chat_list/client_chooser_button.dart b/lib/pages/chat_list/client_chooser_button.dart index 896b6dc36..af21a177a 100644 --- a/lib/pages/chat_list/client_chooser_button.dart +++ b/lib/pages/chat_list/client_chooser_button.dart @@ -154,6 +154,18 @@ class ClientChooserButton extends StatelessWidget { ], ), ), + // #Pangea + PopupMenuItem( + value: SettingsAction.learning, + child: Row( + children: [ + const Icon(Icons.psychology_outlined), + const SizedBox(width: 18), + Expanded(child: Text(L10n.of(context)!.learningSettings)), + ], + ), + ), + // Pangea# PopupMenuItem( value: SettingsAction.settings, child: Row( @@ -382,6 +394,9 @@ class ClientChooserButton extends StatelessWidget { case SettingsAction.setStatus: controller.setStatus(); // #Pangea + case SettingsAction.learning: + context.go('/rooms/settings/learning'); + break; case SettingsAction.newClass: context.go('/rooms/newspace'); break; @@ -493,6 +508,7 @@ enum SettingsAction { settings, archive, // #Pangea + learning, joinWithClassCode, classAnalytics, myAnalytics, From b26d786d9505561e42bb22ea91df43ad4b905f7f Mon Sep 17 00:00:00 2001 From: ggurdin Date: Wed, 15 May 2024 14:18:08 -0400 Subject: [PATCH 9/9] fix for JSON datatype error --- lib/pangea/models/speech_to_text_models.dart | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/pangea/models/speech_to_text_models.dart b/lib/pangea/models/speech_to_text_models.dart index 7d21fd718..dd07f3fc6 100644 --- a/lib/pangea/models/speech_to_text_models.dart +++ b/lib/pangea/models/speech_to_text_models.dart @@ -148,7 +148,7 @@ class STTToken { class Transcript { final String text; final int confidence; - final double? wordsPerMinute; + final int wordsPerMinute; final List sttTokens; final String langCode; @@ -169,7 +169,7 @@ class Transcript { .map((e) => STTToken.fromJson(e)) .toList(), langCode: json['lang_code'], - wordsPerMinute: json['words_per_minute'], + wordsPerMinute: json['words_per_minute'].round(), ); Map toJson() => {