Skip to content

Commit

Permalink
Modifying TTS data format to make processing pass #53
Browse files Browse the repository at this point in the history
  • Loading branch information
MrCsabaToth committed Sep 22, 2024
1 parent eaaa26e commit 85c4e55
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 7 deletions.
3 changes: 1 addition & 2 deletions functions/fn_impl/tts.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,10 +86,9 @@ def tts(req: https_fn.Request) -> https_fn.Response:
synth_blob = bucket.blob(file_name)
synth_blob.upload_from_string(response.audio_content, content_type='audio/ogg')
synth_file_name = synth_blob.public_url.split('/')[-1].split('?')[0]
synth_result = dict(synth_file_name=synth_file_name)

return https_fn.Response(
json.dumps(dict(data=synth_result)),
json.dumps(dict(data=[synth_file_name])),
status=200,
content_type='application/json',
)
10 changes: 5 additions & 5 deletions lib/speech/view/tts_mixin.dart
Original file line number Diff line number Diff line change
Expand Up @@ -55,17 +55,17 @@ mixin TtsMixin {
state.setState(StateBase.ttsStateLabel);
final synthResponse = await FirebaseFunctions.instance
.httpsCallable(ttsFunctionName)
.call<Map<String, String>>({
.call<dynamic>({
'language_code': locale,
'text': responseText,
});

if (synthResponse.data.isNotEmpty &&
synthResponse.data.containsKey('synth_file_name')) {
final synthFileResponse = synthResponse.data as List<Object?>;
if (synthFileResponse.isNotEmpty && synthFileResponse[0] != null) {
state.setState(StateBase.playingStateLabel);
final synthFileName = synthResponse.data['synth_file_name'];
final synthFileName = synthFileResponse[0]! as String;
log('Synth file name: $synthFileName');
if (synthFileName != null && synthFileName.isNotEmpty) {
if (synthFileName.isNotEmpty) {
final synthBytes =
await FirebaseStorage.instance.ref(synthFileName).getData();
if (synthBytes != null && synthBytes.isNotEmpty) {
Expand Down

0 comments on commit 85c4e55

Please sign in to comment.