Merge pull request #277 from Monadical-SAS/force-mp3-download

Force MP3 download
This commit is contained in:
Andreas Bonini
2023-10-13 10:23:46 +01:00
committed by GitHub
2 changed files with 8 additions and 1 deletions

View File

@@ -356,10 +356,14 @@ async def transcript_get_audio_mp3(
if not transcript.audio_mp3_filename.exists():
raise HTTPException(status_code=404, detail="Audio not found")
truncated_id = str(transcript.id).split("-")[0]
filename = f"recording_{truncated_id}.mp3"
return range_requests_response(
request,
transcript.audio_mp3_filename,
content_type="audio/mp3",
content_type="audio/mpeg",
headers={"Content-Disposition": f"attachment; filename={filename}"},
)

View File

@@ -311,6 +311,9 @@ export default function Recorder(props: RecorderProps) {
<a
title="Download recording"
className="text-center cursor-pointer text-blue-400 hover:text-blue-700 ml-2 md:ml:4 p-2 rounded-lg outline-blue-400"
download={`recording-${
props.transcriptId?.split("-")[0] || "0000"
}`}
href={`${process.env.NEXT_PUBLIC_API_URL}/v1/transcripts/${props.transcriptId}/audio/mp3`}
>
<FontAwesomeIcon icon={faDownload} className="h-5 w-auto" />