Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -184,19 +184,27 @@ def transcribe():
|
|
184 |
phone_number = parts[2] if len(parts) > 2 else "0000000000"
|
185 |
print(f"Parsed data - Name: {name}, Email: {email}, Phone Number: {phone_number}")
|
186 |
|
187 |
-
#
|
188 |
-
|
|
|
189 |
|
190 |
-
#
|
191 |
-
|
192 |
|
193 |
-
|
194 |
-
|
195 |
-
|
196 |
-
return jsonify(salesforce_response), 500
|
197 |
|
198 |
-
|
199 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
200 |
|
201 |
except Exception as e:
|
202 |
print(f"Error in transcribing or processing: {str(e)}")
|
@@ -204,4 +212,4 @@ def transcribe():
|
|
204 |
|
205 |
# Start Production Server
|
206 |
if __name__ == "__main__":
|
207 |
-
serve(app, host="0.0.0.0", port=7860)
|
|
|
184 |
phone_number = parts[2] if len(parts) > 2 else "0000000000"
|
185 |
print(f"Parsed data - Name: {name}, Email: {email}, Phone Number: {phone_number}")
|
186 |
|
187 |
+
# Confirm details before submission
|
188 |
+
confirmation = f"Is this correct? Name: {name}, Email: {email}, Phone: {phone_number}"
|
189 |
+
generate_audio_prompt(confirmation, "confirmation.mp3")
|
190 |
|
191 |
+
# Simulate confirmation via user action, in real case this should be handled via front-end
|
192 |
+
user_confirms = True # Assuming the user confirms, you can replace this with actual user input logic
|
193 |
|
194 |
+
if user_confirms:
|
195 |
+
# Create record in Salesforce
|
196 |
+
salesforce_response = create_salesforce_record(name, email, phone_number)
|
|
|
197 |
|
198 |
+
# Log the Salesforce response
|
199 |
+
print(f"Salesforce record creation response: {salesforce_response}")
|
200 |
+
|
201 |
+
# Check if the response contains an error
|
202 |
+
if "error" in salesforce_response:
|
203 |
+
print(f"Error creating record in Salesforce: {salesforce_response['error']}")
|
204 |
+
return jsonify(salesforce_response), 500
|
205 |
+
|
206 |
+
# If creation was successful, return the details
|
207 |
+
return jsonify({"text": transcribed_text, "salesforce_record": salesforce_response})
|
208 |
|
209 |
except Exception as e:
|
210 |
print(f"Error in transcribing or processing: {str(e)}")
|
|
|
212 |
|
213 |
# Start Production Server
|
214 |
if __name__ == "__main__":
|
215 |
+
serve(app, host="0.0.0.0", port=7860)
|