fffiloni commited on
Commit
b7d6c4c
1 Parent(s): f946a20

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +14 -1
app.py CHANGED
@@ -5,11 +5,24 @@ from gradio_client import Client
5
 
6
  client = Client("https://ysharma-explore-llamav2-with-tgi.hf.space/")
7
 
 
 
 
 
 
 
 
 
 
 
 
8
 
9
  def infer(audio_file):
 
 
10
 
11
  cap_result = lpmc_client(
12
- audio_file, # str (filepath or URL to file) in 'audio_path' Audio component
13
  api_name="predict"
14
  )
15
  print(cap_result)
 
5
 
6
  client = Client("https://ysharma-explore-llamav2-with-tgi.hf.space/")
7
 
8
+ from pydub import AudioSegment
9
+
10
+ def cut_audio(input_path, output_path, max_duration=30000):
11
+ audio = AudioSegment.from_file(input_path)
12
+
13
+ if len(audio) > max_duration:
14
+ audio = audio[:max_duration]
15
+
16
+ audio.export(output_path, format="mp3")
17
+
18
+ return output_path
19
 
20
  def infer(audio_file):
21
+
22
+ truncated_audio = cut_audio(audio_file, "trunc_audio.mp3")
23
 
24
  cap_result = lpmc_client(
25
+ truncated_audio, # str (filepath or URL to file) in 'audio_path' Audio component
26
  api_name="predict"
27
  )
28
  print(cap_result)