dn-scribe commited on
Commit
0366707
·
unverified ·
1 Parent(s): ac58a70
Files changed (1) hide show
  1. app.py +5 -7
app.py CHANGED
@@ -11,13 +11,13 @@ import re
11
  logging.basicConfig(level=logging.INFO)
12
  logger = logging.getLogger(__name__)
13
 
14
- def text_to_speech(text):
15
  """
16
  Converts text to speech using gTTS and returns the path to the audio file.
17
  """
18
  if not text:
19
  return None
20
- tts = gTTS(text=text, lang='en')
21
  audio_file = "street_info.mp3"
22
  tts.save(audio_file)
23
  return audio_file
@@ -49,8 +49,6 @@ def get_address(lat, lon):
49
  data = {"display_name": "Error retrieving address"}
50
  return data
51
 
52
- import requests
53
- import logging
54
 
55
  def get_nearby_pois(lat, lon, radius=500, categories=None):
56
  """
@@ -122,14 +120,14 @@ def get_ai_info(street_name):
122
  """
123
  messages = [
124
  {"role": "system", "content": """
125
- You are a whitty tour guide. You know a lot about any area and name, and you can search if needed.
 
126
  You will get as input a town, road name, and points of interest.
127
  You randomly decide about the direction of your answer: either elaborate about the actual location, or the meaining and history of the name given to the street,
128
  or choose a point of interest and elaborate about it. Focus on history, and stories.
129
  Try to find a joke about the subject, or some fun facts.
130
  Maker your answer ready for narration: interesting, storytelling-style with as many puncutiaion marks, pauses and not links or other technical details.
131
  Your answer should be read out in about than 2 minute.
132
- Allways provide an answer in English.
133
  """},
134
  {"role": "user", "content": f"Location information:{street_name}."}
135
  ]
@@ -173,7 +171,7 @@ def process_location(coords):
173
  logging.info(f"Retrieved address: {combined_info}")
174
  ai_info = get_ai_info(address)
175
  ai_info = preprocess_text(ai_info)
176
- audio_file = text_to_speech(ai_info)
177
  return combined_info, ai_info, audio_file
178
  except ValueError:
179
  return "Invalid coordinates provided.", "Unable to retrieve street information.", None
 
11
  logging.basicConfig(level=logging.INFO)
12
  logger = logging.getLogger(__name__)
13
 
14
+ def text_to_speech(text, lang='en'):
15
  """
16
  Converts text to speech using gTTS and returns the path to the audio file.
17
  """
18
  if not text:
19
  return None
20
+ tts = gTTS(text=text, lang=lang)
21
  audio_file = "street_info.mp3"
22
  tts.save(audio_file)
23
  return audio_file
 
49
  data = {"display_name": "Error retrieving address"}
50
  return data
51
 
 
 
52
 
53
  def get_nearby_pois(lat, lon, radius=500, categories=None):
54
  """
 
120
  """
121
  messages = [
122
  {"role": "system", "content": """
123
+ You are a whitty tour guide. You know a lot about any area and name, and you can search if needed.
124
+ You only know to speak English, though you can understand other languages.
125
  You will get as input a town, road name, and points of interest.
126
  You randomly decide about the direction of your answer: either elaborate about the actual location, or the meaining and history of the name given to the street,
127
  or choose a point of interest and elaborate about it. Focus on history, and stories.
128
  Try to find a joke about the subject, or some fun facts.
129
  Maker your answer ready for narration: interesting, storytelling-style with as many puncutiaion marks, pauses and not links or other technical details.
130
  Your answer should be read out in about than 2 minute.
 
131
  """},
132
  {"role": "user", "content": f"Location information:{street_name}."}
133
  ]
 
171
  logging.info(f"Retrieved address: {combined_info}")
172
  ai_info = get_ai_info(address)
173
  ai_info = preprocess_text(ai_info)
174
+ audio_file = None #text_to_speech(ai_info)
175
  return combined_info, ai_info, audio_file
176
  except ValueError:
177
  return "Invalid coordinates provided.", "Unable to retrieve street information.", None