adding words per minute to speech to text feedback

This commit is contained in:
William Jordan-Cooley 2024-05-15 10:57:34 -04:00
parent d29d5ce379
commit 326d2b5fbd
6 changed files with 137 additions and 68 deletions

View file

@ -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
}

View file

@ -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";

View file

@ -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#

View file

@ -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<String, dynamic> json) {
@ -148,6 +148,7 @@ class STTToken {
class Transcript {
final String text;
final int confidence;
final double? wordsPerMinute;
final List<STTToken> 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<String, dynamic> json) => Transcript(
@ -167,6 +169,7 @@ class Transcript {
.map((e) => STTToken.fromJson(e))
.toList(),
langCode: json['lang_code'],
wordsPerMinute: json['words_per_minute'],
);
Map<String, dynamic> 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 {

View file

@ -133,6 +133,9 @@ class MessageSpeechToTextCardState extends State<MessageSpeechToTextCard> {
getSpeechToText();
}
String? get wordsPerMinuteString =>
speechToTextResponse?.transcript.wordsPerMinute?.toString();
@override
Widget build(BuildContext context) {
if (_fetchingTranscription) {
@ -158,11 +161,11 @@ class MessageSpeechToTextCardState extends State<MessageSpeechToTextCard> {
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<MessageSpeechToTextCard> {
),
IconNumberWidget(
icon: Icons.speed,
number: (selectedToken?.confidence ?? total).toString(),
toolTip: L10n.of(context)!.points,
number:
wordsPerMinuteString != null ? "$wordsPerMinuteString" : "??",
toolTip: L10n.of(context)!.wordsPerMinute,
),
],
),

View file

@ -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"
]
}