aazankhanYousafzai commited on
Commit
41847d7
·
verified ·
1 Parent(s): bd0c01b

Create pipeline.py

Browse files
Files changed (1) hide show
  1. pipeline.py +22 -0
pipeline.py ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # pipeline.py
2
+ from stt import speech_to_text
3
+ from llm import ask_llm
4
+ from tts import text_to_speech
5
+
6
+ def voice_to_voice(audio_path):
7
+ if audio_path is None:
8
+ return None, "❌ No audio received"
9
+
10
+ try:
11
+ user_text = speech_to_text(audio_path)
12
+
13
+ if not user_text.strip():
14
+ return None, "❌ Could not understand audio"
15
+
16
+ ai_text = ask_llm(user_text)
17
+ ai_audio = text_to_speech(ai_text)
18
+
19
+ return ai_audio, ai_text
20
+
21
+ except Exception as e:
22
+ return None, f"❌ Error: {str(e)}"