Adityadn commited on
Commit
ae714b0
·
verified ·
1 Parent(s): 54ced95

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -4
app.py CHANGED
@@ -5,7 +5,7 @@ from acrcloud.recognizer import ACRCloudRecognizer
5
  # Retrieve ACRCloud credentials from environment variables
6
  acr_access_key = os.environ.get('ACR_ACCESS_KEY')
7
  acr_access_secret = os.environ.get('ACR_ACCESS_SECRET')
8
- acr_host = 'identify-ap-southeast-1.acrcloud.com'
9
 
10
  # ACRCloud recognizer configuration
11
  config = {
@@ -19,12 +19,12 @@ config = {
19
  acr = ACRCloudRecognizer(config)
20
 
21
  def identify_audio(file):
22
- # Save the uploaded file temporarily
23
  file_path = "temp_audio_file" + os.path.splitext(file.name)[-1] # Preserve the file extension
24
 
25
- # Write the uploaded file to disk
26
  with open(file_path, 'wb') as f:
27
- f.write(file.read()) # Write the content of the uploaded file
28
 
29
  # Get the duration of the audio file in milliseconds
30
  duration_ms = int(acr.get_duration_ms_by_file(file_path))
 
5
  # Retrieve ACRCloud credentials from environment variables
6
  acr_access_key = os.environ.get('ACR_ACCESS_KEY')
7
  acr_access_secret = os.environ.get('ACR_ACCESS_SECRET')
8
+ acr_host = os.environ.get('ACR_HOST', 'eu-west-1.api.acrcloud.com')
9
 
10
  # ACRCloud recognizer configuration
11
  config = {
 
19
  acr = ACRCloudRecognizer(config)
20
 
21
  def identify_audio(file):
22
+ # Create a temporary file path
23
  file_path = "temp_audio_file" + os.path.splitext(file.name)[-1] # Preserve the file extension
24
 
25
+ # Open the uploaded file using the file object provided by Gradio
26
  with open(file_path, 'wb') as f:
27
+ f.write(file.read()) # Write the content of the uploaded file to disk
28
 
29
  # Get the duration of the audio file in milliseconds
30
  duration_ms = int(acr.get_duration_ms_by_file(file_path))