Simonlob commited on
Commit
ddbbef2
1 Parent(s): 170b7fb

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +10 -3
app.py CHANGED
@@ -21,13 +21,14 @@ sentry_sdk.init(
21
  dsn="https://26932c88424672dea1c43f8536dd6a0d@o4508269800849408.ingest.us.sentry.io/4508269808254976",
22
  )
23
 
24
- def log_user_request(user_input: str, speaking_rate:float, device:str):
25
  """
26
  Logs the user's request and the current date in Sentry.
27
  Args:
28
  user_input (str): User entered text.
29
  speaking_rate (float): Rate of speech.
30
  device (str): Available device.
 
31
  """
32
 
33
  current_datetime = datetime.now().strftime("%Y-%m-%d %H:%M:%S")
@@ -38,6 +39,7 @@ def log_user_request(user_input: str, speaking_rate:float, device:str):
38
  scope.set_extra("speaking_rate", str(speaking_rate))
39
  scope.set_extra("device", device)
40
  scope.set_extra("timestamp", current_datetime)
 
41
 
42
  sentry_sdk.capture_message("User request")
43
 
@@ -132,8 +134,13 @@ vocoder, denoiser = load_vocoder(vocoder_path, device)
132
 
133
  def gen_tts(text, speaking_rate):
134
  try:
135
- log_user_request(text, speaking_rate, device)
136
- return 22050, get_inference(text = text, length_scale = speaking_rate)
 
 
 
 
 
137
  except Exception as e:
138
  sentry_sdk.capture_exception(e)
139
 
 
21
  dsn="https://26932c88424672dea1c43f8536dd6a0d@o4508269800849408.ingest.us.sentry.io/4508269808254976",
22
  )
23
 
24
+ def log_user_request(user_input: str, speaking_rate:float, device:str, execution_time:str):
25
  """
26
  Logs the user's request and the current date in Sentry.
27
  Args:
28
  user_input (str): User entered text.
29
  speaking_rate (float): Rate of speech.
30
  device (str): Available device.
31
+ execution_time (str): Generation time in seconds
32
  """
33
 
34
  current_datetime = datetime.now().strftime("%Y-%m-%d %H:%M:%S")
 
39
  scope.set_extra("speaking_rate", str(speaking_rate))
40
  scope.set_extra("device", device)
41
  scope.set_extra("timestamp", current_datetime)
42
+ scope.set_extra("execution_time", f'{execution_time} sec')
43
 
44
  sentry_sdk.capture_message("User request")
45
 
 
134
 
135
  def gen_tts(text, speaking_rate):
136
  try:
137
+ start_time = datetime.now()
138
+ output = 22050, get_inference(text = text, length_scale = speaking_rate)
139
+ end_time = datetime.now()
140
+ execution_time = str((end_time - start_time).total_seconds())
141
+
142
+ log_user_request(text, speaking_rate, device, execution_time)
143
+ return output
144
  except Exception as e:
145
  sentry_sdk.capture_exception(e)
146