audio stuff

pull/1011/head
Gabby Gurdin 2 years ago
parent c70a598014
commit 0a438fdcf2

@ -6,7 +6,6 @@ import 'package:fluffychat/pangea/config/environment.dart';
import 'package:fluffychat/pangea/constants/model_keys.dart'; import 'package:fluffychat/pangea/constants/model_keys.dart';
import 'package:fluffychat/pangea/controllers/pangea_controller.dart'; import 'package:fluffychat/pangea/controllers/pangea_controller.dart';
import 'package:fluffychat/pangea/network/urls.dart'; import 'package:fluffychat/pangea/network/urls.dart';
import 'package:flutter/material.dart';
import 'package:http/http.dart'; import 'package:http/http.dart';
import '../network/requests.dart'; import '../network/requests.dart';
@ -37,15 +36,17 @@ class TextToSpeechRequest {
class TextToSpeechResponse { class TextToSpeechResponse {
String audioContent; String audioContent;
String mediaType; String mimeType;
int durationMillis; int durationMillis;
List<int> waveform; List<int> waveform;
String fileExtension;
TextToSpeechResponse({ TextToSpeechResponse({
required this.audioContent, required this.audioContent,
required this.mediaType, required this.mimeType,
required this.durationMillis, required this.durationMillis,
required this.waveform, required this.waveform,
required this.fileExtension,
}); });
factory TextToSpeechResponse.fromJson( factory TextToSpeechResponse.fromJson(
@ -53,9 +54,10 @@ class TextToSpeechResponse {
) => ) =>
TextToSpeechResponse( TextToSpeechResponse(
audioContent: json["audio_content"], audioContent: json["audio_content"],
mediaType: json["media_type"], mimeType: json["mime_type"],
durationMillis: json["duration_millis"], durationMillis: json["duration_millis"],
waveform: List<int>.from(json["wave_form"]), waveform: List<int>.from(json["wave_form"]),
fileExtension: json["file_extension"],
); );
} }

@ -114,12 +114,13 @@ class PangeaMessageEvent {
// final fileName = // final fileName =
// text.trim().replaceAll(RegExp('[^A-Za-z0-9]'), '').substring(0, 20); // text.trim().replaceAll(RegExp('[^A-Za-z0-9]'), '').substring(0, 20);
final eventIdParam = _event.eventId; final eventIdParam = _event.eventId;
final fileName = "audio_for_${eventIdParam}_$langCode.mp3"; final fileName =
"audio_for_${eventIdParam}_$langCode.${response.fileExtension}";
final file = MatrixAudioFile( final file = MatrixAudioFile(
bytes: audioBytes, bytes: audioBytes,
name: fileName, name: fileName,
mimeType: "audio/mpeg", mimeType: response.mimeType,
); );
// try { // try {

Loading…
Cancel
Save