Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -122,7 +122,7 @@ async def audio_to_text_endpoint(file: UploadFile, language: str = 'fr-FR'):
|
|
122 |
# Raise an HTTP 500 error if any exceptions occur
|
123 |
raise HTTPException(status_code=500, detail=f"An error occurred while processing the file: {e}")
|
124 |
|
125 |
-
@app.post("/audio-to-offer-endpoint/")
|
126 |
async def audio_to_offer_endpoint(file: UploadFile, language: str, api_key: str):
|
127 |
"""
|
128 |
Endpoint to convert uploaded audio content to a job offer text.
|
@@ -138,8 +138,7 @@ async def audio_to_offer_endpoint(file: UploadFile, language: str, api_key: str)
|
|
138 |
Raises:
|
139 |
- HTTPException: If an error occurs during the processing of the audio or the generation of the job offer.
|
140 |
"""
|
141 |
-
|
142 |
-
print(api_key)
|
143 |
try:
|
144 |
text_response = await audio_to_text_endpoint(file, language)
|
145 |
text = text_response["text"]
|
@@ -147,6 +146,28 @@ async def audio_to_offer_endpoint(file: UploadFile, language: str, api_key: str)
|
|
147 |
return {"text": offer}
|
148 |
except Exception as e:
|
149 |
raise HTTPException(status_code=500, detail=f"Error generating job offer: {e}")
|
150 |
-
|
151 |
-
|
152 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
122 |
# Raise an HTTP 500 error if any exceptions occur
|
123 |
raise HTTPException(status_code=500, detail=f"An error occurred while processing the file: {e}")
|
124 |
|
125 |
+
@app.post("/audio-to-offer-with-gemini-endpoint/")
|
126 |
async def audio_to_offer_endpoint(file: UploadFile, language: str, api_key: str):
|
127 |
"""
|
128 |
Endpoint to convert uploaded audio content to a job offer text.
|
|
|
138 |
Raises:
|
139 |
- HTTPException: If an error occurs during the processing of the audio or the generation of the job offer.
|
140 |
"""
|
141 |
+
|
|
|
142 |
try:
|
143 |
text_response = await audio_to_text_endpoint(file, language)
|
144 |
text = text_response["text"]
|
|
|
146 |
return {"text": offer}
|
147 |
except Exception as e:
|
148 |
raise HTTPException(status_code=500, detail=f"Error generating job offer: {e}")
|
149 |
+
|
150 |
+
@app.post("/audio-to-offer-with-gpt-endpoint/")
|
151 |
+
async def audio_to_offer_endpoint(file: UploadFile, language: str, api_key: str):
|
152 |
+
"""
|
153 |
+
Endpoint to convert uploaded audio content to a job offer text.
|
154 |
+
|
155 |
+
Parameters:
|
156 |
+
- file (UploadFile): The audio file uploaded by the client. The file should be in .wav format.
|
157 |
+
- language (str): Language code to guide the speech recognition process. Default is French ('fr-FR').
|
158 |
+
- api_key (str, optional): API key for accessing extended features or third-party services used in generating the job offer.
|
159 |
+
|
160 |
+
Returns:
|
161 |
+
- A JSON object with a key 'offer' containing the generated job description text based on the audio content.
|
162 |
+
|
163 |
+
Raises:
|
164 |
+
- HTTPException: If an error occurs during the processing of the audio or the generation of the job offer.
|
165 |
+
"""
|
166 |
+
|
167 |
+
try:
|
168 |
+
text_response = await audio_to_text_endpoint(file, language)
|
169 |
+
text = text_response["text"]
|
170 |
+
offer = generate_job_description_gpt(text, api_key)
|
171 |
+
return {"text": offer}
|
172 |
+
except Exception as e:
|
173 |
+
raise HTTPException(status_code=500, detail=f"Error generating job offer: {e}")
|