DSatishchandra commited on
Commit
e0fd1d2
·
verified ·
1 Parent(s): c7f6351

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +10 -1
app.py CHANGED
@@ -69,10 +69,14 @@ def create_salesforce_record(name, email, phone_number):
69
  'Email__c': email,
70
  'Phone_Number__c': phone_number
71
  })
 
72
  return customer_login
73
  except Exception as e:
 
 
74
  return {"error": f"Failed to create record in Salesforce: {str(e)}"}
75
 
 
76
  @app.route("/")
77
  def index():
78
  return render_template("index.html")
@@ -107,15 +111,20 @@ def transcribe():
107
 
108
  # Create record in Salesforce
109
  salesforce_response = create_salesforce_record(name, email, phone_number)
110
-
 
111
  if "error" in salesforce_response:
 
112
  return jsonify(salesforce_response), 500
113
 
 
114
  return jsonify({"text": transcribed_text, "salesforce_record": salesforce_response})
115
 
116
  except Exception as e:
 
117
  return jsonify({"error": f"Speech recognition error: {str(e)}"}), 500
118
 
 
119
  # Start Production Server
120
  if __name__ == "__main__":
121
  serve(app, host="0.0.0.0", port=7860)
 
69
  'Email__c': email,
70
  'Phone_Number__c': phone_number
71
  })
72
+ print("Salesforce record created successfully:", customer_login)
73
  return customer_login
74
  except Exception as e:
75
+ # Print the error to the console and log it for troubleshooting
76
+ print(f"Error creating Salesforce record: {str(e)}")
77
  return {"error": f"Failed to create record in Salesforce: {str(e)}"}
78
 
79
+
80
  @app.route("/")
81
  def index():
82
  return render_template("index.html")
 
111
 
112
  # Create record in Salesforce
113
  salesforce_response = create_salesforce_record(name, email, phone_number)
114
+
115
+ # Check if the response contains an error
116
  if "error" in salesforce_response:
117
+ print(f"Error creating record in Salesforce: {salesforce_response['error']}")
118
  return jsonify(salesforce_response), 500
119
 
120
+ print(f"Salesforce Response: {salesforce_response}")
121
  return jsonify({"text": transcribed_text, "salesforce_record": salesforce_response})
122
 
123
  except Exception as e:
124
+ print(f"Error in transcribing or processing: {str(e)}")
125
  return jsonify({"error": f"Speech recognition error: {str(e)}"}), 500
126
 
127
+
128
  # Start Production Server
129
  if __name__ == "__main__":
130
  serve(app, host="0.0.0.0", port=7860)