From 0281e206db1629192e439e3879921f2d1e63f01e Mon Sep 17 00:00:00 2001 From: Brandon Thomas Date: Tue, 9 Jun 2020 19:20:01 -0400 Subject: [PATCH] second attempt at iphone content-range fix --- tts_service/src/endpoints/legacy_speak.rs | 6 ++++-- tts_service/src/endpoints/speak.rs | 6 ++++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/tts_service/src/endpoints/legacy_speak.rs b/tts_service/src/endpoints/legacy_speak.rs index c9d6b0f47c..b54515426f 100644 --- a/tts_service/src/endpoints/legacy_speak.rs +++ b/tts_service/src/endpoints/legacy_speak.rs @@ -154,10 +154,11 @@ pub async fn legacy_get_speak(request: HttpRequest, // Content-Type: audio/wav // Content-Disposition: // Content-Length: len() + let content_range_value = format!("bytes 0-{}/{}", wav_data.len(), wav_data.len()); Ok(HttpResponse::build(StatusCode::OK) .content_type("audio/wav") .set_header(header::CONTENT_DISPOSITION, "attachment; filename = \"generated.wav\"") - .set_header(header::CONTENT_RANGE, "bytes */*") + .set_header(header::CONTENT_RANGE, content_range_value) .body(wav_data)) }, } @@ -209,10 +210,11 @@ pub async fn legacy_get_speak(request: HttpRequest, // Content-Type: audio/wav // Content-Disposition: // Content-Length: len() + let content_range_value = format!("bytes 0-{}/{}", wav_data.len(), wav_data.len()); Ok(HttpResponse::build(StatusCode::OK) .content_type("audio/wav") .set_header(header::CONTENT_DISPOSITION, "attachment; filename = \"generated.wav\"") - .set_header(header::CONTENT_RANGE, "bytes */*") + .set_header(header::CONTENT_RANGE, content_range_value) .body(wav_data)) }, ModelPipeline::RawTextTacotronMelgan => unimplemented!(), diff --git a/tts_service/src/endpoints/speak.rs b/tts_service/src/endpoints/speak.rs index f417e27634..67f094be06 100644 --- a/tts_service/src/endpoints/speak.rs +++ b/tts_service/src/endpoints/speak.rs @@ -107,10 +107,11 @@ pub async fn post_speak(request: HttpRequest, Some(wav_data) => { // To make iOS Safari work, you need a Content-Range and Content-Length header: // https://stackoverflow.com/a/17835399 + let content_range_value = format!("bytes 0-{}/{}", wav_data.len(), wav_data.len()); Ok(HttpResponse::build(StatusCode::OK) .content_type("audio/wav") .set_header(header::CONTENT_DISPOSITION, "attachment; filename = \"generated.wav\"") - .set_header(header::CONTENT_RANGE, "bytes */*") + .set_header(header::CONTENT_RANGE, content_range_value) .body(wav_data)) }, } @@ -140,10 +141,11 @@ pub async fn post_speak(request: HttpRequest, // To make iOS Safari work, you need a Content-Range and Content-Length header: // https://stackoverflow.com/a/17835399 + let content_range_value = format!("bytes 0-{}/{}", wav_data.len(), wav_data.len()); Ok(HttpResponse::build(StatusCode::OK) .content_type("audio/wav") .set_header(header::CONTENT_DISPOSITION, "attachment; filename = \"generated.wav\"") - .set_header(header::CONTENT_RANGE, "bytes */*") + .set_header(header::CONTENT_RANGE, content_range_value) .body(wav_data)) }, ModelPipeline::RawTextTacotronMelgan => unimplemented!(),