added fix for different map keys in voices across platforms
This commit is contained in:
parent
162019221a
commit
8a24b0342b
3 changed files with 15 additions and 18 deletions
|
|
@ -45,18 +45,24 @@ extension PangeaEvent on Event {
|
|||
Future<PangeaAudioFile?> getPangeaAudioFile() async {
|
||||
if (type != EventTypes.Message || messageType != MessageTypes.Audio) {
|
||||
ErrorHandler.logError(
|
||||
e: "Event $eventId is not an audio message",
|
||||
e: "Event is not an audio message",
|
||||
data: {
|
||||
"event": toJson(),
|
||||
},
|
||||
);
|
||||
return null;
|
||||
}
|
||||
|
||||
// @ggurdin what are cases where these would be null?
|
||||
// if it would be unexpected, we should log an error with details to investigate
|
||||
final transcription =
|
||||
content.tryGetMap<String, dynamic>(ModelKey.transcription);
|
||||
final audioContent =
|
||||
content.tryGetMap<String, dynamic>('org.matrix.msc1767.audio');
|
||||
if (transcription == null || audioContent == null) return null;
|
||||
if (transcription == null || audioContent == null) {
|
||||
ErrorHandler.logError(
|
||||
e: "Called getPangeaAudioFile on an audio message without transcription or audio content",
|
||||
);
|
||||
return null;
|
||||
}
|
||||
|
||||
final matrixFile = await downloadAndDecryptAttachment();
|
||||
final duration = audioContent.tryGet<int>('duration');
|
||||
|
|
|
|||
|
|
@ -56,12 +56,6 @@ class MessageAudioCardState extends State<MessageAudioCard> {
|
|||
|
||||
@override
|
||||
void didUpdateWidget(covariant oldWidget) {
|
||||
// @ggurdin did you find a case of needing to reinitialize TTS because of a language change?
|
||||
// if (widget.messageEvent.messageDisplayLangCode !=
|
||||
// oldWidget.messageEvent.messageDisplayLangCode) {
|
||||
// initializeTTS();
|
||||
// }
|
||||
|
||||
if (oldWidget.selection != widget.selection) {
|
||||
debugPrint('selection changed');
|
||||
setSectionStartAndEndFromSelection();
|
||||
|
|
|
|||
|
|
@ -35,15 +35,13 @@ class TtsController {
|
|||
await tts.awaitSpeakCompletion(true);
|
||||
|
||||
final voices = await tts.getVoices;
|
||||
debugPrint("voices: $voices");
|
||||
availableLangCodes = (voices as List)
|
||||
.map((v) {
|
||||
// debugPrint('v: $v');
|
||||
|
||||
//@ggurdin i changed this from name to locale
|
||||
//in my testing, that's where the language code is stored
|
||||
// maybe it's different for different devices? was it different in your android testing?
|
||||
// return v['name']?.split("-").first;
|
||||
return v['locale']?.split("-").first;
|
||||
// on iOS / web, the codes are in 'locale', but on Android, they are in 'name'
|
||||
final nameCode = v['name']?.split("-").first;
|
||||
final localeCode = v['locale']?.split("-").first;
|
||||
return nameCode.length == 2 ? nameCode : localeCode;
|
||||
})
|
||||
.toSet()
|
||||
.cast<String>()
|
||||
|
|
@ -67,7 +65,6 @@ class TtsController {
|
|||
bool get isLanguageFullySupported =>
|
||||
availableLangCodes.contains(targetLanguage);
|
||||
|
||||
// @ggurdin
|
||||
Widget get missingVoiceButton => targetLanguage != null &&
|
||||
(kIsWeb || isLanguageFullySupported || !PlatformInfos.isAndroid)
|
||||
? const SizedBox.shrink()
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue