mkozak commited on
Commit
2c12c7a
·
unverified ·
1 Parent(s): fa944b2
Files changed (1) hide show
  1. main.py +5 -5
main.py CHANGED
@@ -5,9 +5,9 @@ import boto3
5
  app = FastAPI()
6
 
7
  # Define your AWS S3 credentials and bucket name
8
- aws_access_key_id = 'YOUR_AWS_ACCESS_KEY_ID'
9
- aws_secret_access_key = 'YOUR_AWS_SECRET_ACCESS_KEY'
10
- s3_bucket_name = 'YOUR_S3_BUCKET_NAME'
11
 
12
  # Initialize an S3 client
13
  s3_client = boto3.client('s3', aws_access_key_id=aws_access_key_id, aws_secret_access_key=aws_secret_access_key)
@@ -22,7 +22,7 @@ async def merge_audio(output_key: str):
22
  quote_file = temp_dir + 'quote.mp3'
23
 
24
  # Download files from S3 based on the provided key
25
- s3_directory = 'your-s3-directory/' + output_key
26
  s3_gen_base_key = f'{s3_directory}/genBase.mp3'
27
  s3_quote_key = f'{s3_directory}/quote.mp3'
28
 
@@ -45,7 +45,7 @@ async def merge_audio(output_key: str):
45
  raise HTTPException(status_code=500, detail=f"FFmpeg Error: {e}")
46
 
47
  # Upload the merged file back to S3
48
- s3_output_key = f'{s3_directory}/output.mp3'
49
  try:
50
  s3_client.upload_file(output_file, s3_bucket_name, s3_output_key)
51
  except Exception as e:
 
5
  app = FastAPI()
6
 
7
  # Define your AWS S3 credentials and bucket name
8
+ aws_access_key_id = ENV['AWS_ACCESS_KEY_ID']
9
+ aws_secret_access_key = ENV['AWS_SECRET_ACCESS_KEY']
10
+ s3_bucket_name = ENV['S3_BUCKET_NAME']
11
 
12
  # Initialize an S3 client
13
  s3_client = boto3.client('s3', aws_access_key_id=aws_access_key_id, aws_secret_access_key=aws_secret_access_key)
 
22
  quote_file = temp_dir + 'quote.mp3'
23
 
24
  # Download files from S3 based on the provided key
25
+ s3_directory = output_key
26
  s3_gen_base_key = f'{s3_directory}/genBase.mp3'
27
  s3_quote_key = f'{s3_directory}/quote.mp3'
28
 
 
45
  raise HTTPException(status_code=500, detail=f"FFmpeg Error: {e}")
46
 
47
  # Upload the merged file back to S3
48
+ s3_output_key = f'{s3_directory}/final.mp3'
49
  try:
50
  s3_client.upload_file(output_file, s3_bucket_name, s3_output_key)
51
  except Exception as e: