Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -16,15 +16,20 @@ FLUX1_APIKEY = os.getenv('FLUX1_APIKEY')
|
|
| 16 |
# LLM
|
| 17 |
GEMINI_APIKEY = os.getenv('GEMINI_APIKEY')
|
| 18 |
# Modèle Whisper pour la transcription audio
|
| 19 |
-
|
| 20 |
-
WHISPER_MODEL = InferenceClient(api_url=WHISPER_MODEL_URL, token=os.getenv('HUGGINGFACE_API_KEY'))
|
| 21 |
|
| 22 |
-
def
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
|
| 27 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 28 |
|
| 29 |
def GenerateTextLLM(inputText):
|
| 30 |
url = f'https://generativelanguage.googleapis.com/v1beta/models/gemini-1.5-flash-latest:generateContent?key={GEMINI_APIKEY}'
|
|
@@ -64,7 +69,7 @@ def Main(text_input, audio_input):
|
|
| 64 |
if text_input:
|
| 65 |
input_data = text_input
|
| 66 |
elif audio_input:
|
| 67 |
-
input_data =
|
| 68 |
else:
|
| 69 |
return "Veuillez fournir un texte ou un fichier audio", None
|
| 70 |
|
|
|
|
| 16 |
# LLM
|
| 17 |
GEMINI_APIKEY = os.getenv('GEMINI_APIKEY')
|
| 18 |
# Modèle Whisper pour la transcription audio
|
| 19 |
+
WHISPER_APIKEY = os.getenv('WHISPER_APIKEY')
|
|
|
|
| 20 |
|
| 21 |
+
def TranscribeAudio(inputAudio):
|
| 22 |
+
|
| 23 |
+
API_URL = "https://api-inference.huggingface.co/models/openai/whisper-large-v3"
|
| 24 |
+
headers = {"Authorization": f"Bearer {WHISPER_APIKEY}"}
|
| 25 |
+
|
| 26 |
+
def query(filename):
|
| 27 |
+
with open(filename, "rb") as f:
|
| 28 |
+
data = f.read()
|
| 29 |
+
response = requests.post(API_URL, headers=headers, data=data)
|
| 30 |
+
return response.json()
|
| 31 |
+
|
| 32 |
+
output = query("sample1.flac")
|
| 33 |
|
| 34 |
def GenerateTextLLM(inputText):
|
| 35 |
url = f'https://generativelanguage.googleapis.com/v1beta/models/gemini-1.5-flash-latest:generateContent?key={GEMINI_APIKEY}'
|
|
|
|
| 69 |
if text_input:
|
| 70 |
input_data = text_input
|
| 71 |
elif audio_input:
|
| 72 |
+
input_data = TranscribeAudio(audio_input)
|
| 73 |
else:
|
| 74 |
return "Veuillez fournir un texte ou un fichier audio", None
|
| 75 |
|