Spaces:
Build error
Build error
upload file that has been cutted
Browse files
main.py
CHANGED
|
@@ -22,14 +22,7 @@ class CutRequest(BaseModel):
|
|
| 22 |
def download_files(output_key: str):
|
| 23 |
# Temporary directory to store uploaded audio files
|
| 24 |
|
| 25 |
-
# Local paths for the fixed input audio files
|
| 26 |
-
gen_base_file = temp_dir + 'genBase.mp3'
|
| 27 |
-
quote_file = temp_dir + 'quote.mp3'
|
| 28 |
-
|
| 29 |
-
# Download files from S3 based on the provided key
|
| 30 |
s3_directory = output_key
|
| 31 |
-
s3_gen_base_key = f'{s3_directory}/genBase.mp3'
|
| 32 |
-
s3_quote_key = f'{s3_directory}/quote.mp3'
|
| 33 |
|
| 34 |
input_files = ['genBase.mp3', 'quote.mp3']
|
| 35 |
try:
|
|
@@ -54,6 +47,12 @@ def cut_audio(request: CutRequest, output_key: str):
|
|
| 54 |
)
|
| 55 |
except ffmpeg.Error as e:
|
| 56 |
raise HTTPException(status_code=500, detail=str(e))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 57 |
return {"message": "Audio cut successfully"}
|
| 58 |
|
| 59 |
|
|
|
|
| 22 |
def download_files(output_key: str):
|
| 23 |
# Temporary directory to store uploaded audio files
|
| 24 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 25 |
s3_directory = output_key
|
|
|
|
|
|
|
| 26 |
|
| 27 |
input_files = ['genBase.mp3', 'quote.mp3']
|
| 28 |
try:
|
|
|
|
| 47 |
)
|
| 48 |
except ffmpeg.Error as e:
|
| 49 |
raise HTTPException(status_code=500, detail=str(e))
|
| 50 |
+
try:
|
| 51 |
+
s3_output_key = f'{output_key}/genBase_segment_{i}.mp3'
|
| 52 |
+
s3_client.upload_file(output_file, s3_bucket_name, s3_output_key)
|
| 53 |
+
except Exception as e:
|
| 54 |
+
raise HTTPException(status_code=500, detail=f"Failed to upload file to S3: {e}")
|
| 55 |
+
|
| 56 |
return {"message": "Audio cut successfully"}
|
| 57 |
|
| 58 |
|