Merge pull request #1006 from pangeachat/1004-error-in-message-audio

if pangea rep is null, still get and save text to speech event
This commit is contained in:
ggurdin 2024-11-14 13:14:13 -05:00 committed by GitHub
commit fd8bce5b7d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

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