Spaces:
Running
on
T4
Running
on
T4
beweinreich
commited on
Commit
•
cd7af42
1
Parent(s):
3a642f3
update with audio / video url and gpu version of torch
Browse files- app.py +2 -0
- audio_analyzer.py +4 -3
- requirements.txt +1 -0
app.py
CHANGED
@@ -22,6 +22,7 @@ async def analyze_audio(request: AudioRequest):
|
|
22 |
if not audio_url:
|
23 |
raise HTTPException(status_code=400, detail="audio_url is required")
|
24 |
|
|
|
25 |
analyzer = AudioAnalyzer(media_url=audio_url, media_type="audio")
|
26 |
traits = analyzer.retrieve_traits()
|
27 |
|
@@ -34,6 +35,7 @@ async def analyze_video(request: VideoRequest):
|
|
34 |
if not video_url:
|
35 |
raise HTTPException(status_code=400, detail="video_url is required")
|
36 |
|
|
|
37 |
analyzer = VideoAnalyzer(video_url=video_url)
|
38 |
traits = analyzer.retrieve_traits()
|
39 |
|
|
|
22 |
if not audio_url:
|
23 |
raise HTTPException(status_code=400, detail="audio_url is required")
|
24 |
|
25 |
+
print(f"Analyzing audio... {audio_url}")
|
26 |
analyzer = AudioAnalyzer(media_url=audio_url, media_type="audio")
|
27 |
traits = analyzer.retrieve_traits()
|
28 |
|
|
|
35 |
if not video_url:
|
36 |
raise HTTPException(status_code=400, detail="video_url is required")
|
37 |
|
38 |
+
print(f"Analyzing video... {video_url}")
|
39 |
analyzer = VideoAnalyzer(video_url=video_url)
|
40 |
traits = analyzer.retrieve_traits()
|
41 |
|
audio_analyzer.py
CHANGED
@@ -16,6 +16,7 @@ TWILIO_ACCOUNT_SID = os.getenv("TWILIO_ACCOUNT_SID")
|
|
16 |
TWILIO_AUTH_TOKEN = os.getenv("TWILIO_AUTH_TOKEN")
|
17 |
client = OpenAI(api_key=OPENAI_API_KEY)
|
18 |
|
|
|
19 |
class AudioAnalyzer:
|
20 |
def __init__(self, media_path=None, media_url=None, media_type=None):
|
21 |
self.personality_labels = [
|
@@ -23,7 +24,7 @@ class AudioAnalyzer:
|
|
23 |
"Creative", "Analytical", "Dependable", "Impulsive", "Adaptable", "Meticulous", "Assertive",
|
24 |
"Agreeable", "Courageous", "Cautious", "Patient", "Ambitious", "Generous"
|
25 |
]
|
26 |
-
self.personality_pipeline = pipeline("zero-shot-classification", model="facebook/bart-large-mnli")
|
27 |
self.media_path = media_path
|
28 |
self.media_url = media_url
|
29 |
self.media_type = media_type
|
@@ -81,8 +82,8 @@ class AudioAnalyzer:
|
|
81 |
for chunk in chunks:
|
82 |
processed_audio += chunk
|
83 |
|
84 |
-
# trim to
|
85 |
-
processed_audio = processed_audio[:
|
86 |
|
87 |
# Export as mp3
|
88 |
processed_audio.export(mp3_file, format="mp3", bitrate=bitrate)
|
|
|
16 |
TWILIO_AUTH_TOKEN = os.getenv("TWILIO_AUTH_TOKEN")
|
17 |
client = OpenAI(api_key=OPENAI_API_KEY)
|
18 |
|
19 |
+
|
20 |
class AudioAnalyzer:
|
21 |
def __init__(self, media_path=None, media_url=None, media_type=None):
|
22 |
self.personality_labels = [
|
|
|
24 |
"Creative", "Analytical", "Dependable", "Impulsive", "Adaptable", "Meticulous", "Assertive",
|
25 |
"Agreeable", "Courageous", "Cautious", "Patient", "Ambitious", "Generous"
|
26 |
]
|
27 |
+
# self.personality_pipeline = pipeline("zero-shot-classification", model="facebook/bart-large-mnli")
|
28 |
self.media_path = media_path
|
29 |
self.media_url = media_url
|
30 |
self.media_type = media_type
|
|
|
82 |
for chunk in chunks:
|
83 |
processed_audio += chunk
|
84 |
|
85 |
+
# trim to 2 minutes
|
86 |
+
processed_audio = processed_audio[:120000]
|
87 |
|
88 |
# Export as mp3
|
89 |
processed_audio.export(mp3_file, format="mp3", bitrate=bitrate)
|
requirements.txt
CHANGED
@@ -1,3 +1,4 @@
|
|
|
|
1 |
fastapi==0.111.1
|
2 |
imageio==2.34.1
|
3 |
moviepy==1.0.3
|
|
|
1 |
+
--extra-index-url https://download.pytorch.org/whl/cu113
|
2 |
fastapi==0.111.1
|
3 |
imageio==2.34.1
|
4 |
moviepy==1.0.3
|