Skip to content

Commit

Permalink
Merge pull request #1006 from pangeachat/1004-error-in-message-audio
Browse files Browse the repository at this point in the history
if pangea rep is null, still get and save text to speech event
  • Loading branch information
ggurdin authored Nov 14, 2024
2 parents c51e3c4 + f6c57dd commit fd8bce5
Showing 1 changed file with 9 additions and 10 deletions.
19 changes: 9 additions & 10 deletions lib/pangea/matrix_event_wrappers/pangea_message_event.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -118,7 +117,7 @@ class PangeaMessageEvent {
tokens: response.ttsTokens,
);

sendAudioEvent(file, response, rep.text, langCode);
sendAudioEvent(file, response, rep?.text ?? body, langCode);

return file;
}
Expand Down

0 comments on commit fd8bce5

Please sign in to comment.