if pangea rep is null, still get and save text to speech event

This commit is contained in:
ggurdin 2024-11-14 13:13:39 -05:00
parent c51e3c4227
commit f6c57ddc48
No known key found for this signature in database
GPG key ID: A01CB41737CBB478

View file

@ -84,16 +84,15 @@ class PangeaMessageEvent {
) async {
final RepresentationEvent? rep = representationByLanguage(langCode);
if (rep == null) return null;
final TextToSpeechRequest params = TextToSpeechRequest(
text: rep.content.text,
tokens: (await rep.tokensGlobal(
senderId,
originServerTs,
))
.map((t) => t.text)
.toList(),
text: rep?.content.text ?? body,
tokens: (await rep?.tokensGlobal(
senderId,
originServerTs,
))
?.map((t) => t.text)
.toList() ??
[],
langCode: langCode,
userL1: l1Code ?? LanguageKeys.unknownLanguage,
userL2: l2Code ?? LanguageKeys.unknownLanguage,
@ -118,7 +117,7 @@ class PangeaMessageEvent {
tokens: response.ttsTokens,
);
sendAudioEvent(file, response, rep.text, langCode);
sendAudioEvent(file, response, rep?.text ?? body, langCode);
return file;
}