chore: Update TTS dependencies and remove unused imports
Browse files- kitt/core/__init__.py +1 -1
- kitt/core/model.py +2 -2
- kitt/core/tts.py +10 -0
- kitt/core/utils.py +1 -1
- kitt/keepalive.py +1 -1
- kitt/skills/weather.py +3 -3
- main.py +7 -5
kitt/core/__init__.py
CHANGED
|
@@ -38,7 +38,7 @@ voices = [
|
|
| 38 |
Voice(
|
| 39 |
"Freeman",
|
| 40 |
neutral=f"{file_full_path}/audio/freeman/neutral.wav",
|
| 41 |
-
angry="audio/freeman/angry.wav",
|
| 42 |
speed=1.1,
|
| 43 |
),
|
| 44 |
Voice(
|
|
|
|
| 38 |
Voice(
|
| 39 |
"Freeman",
|
| 40 |
neutral=f"{file_full_path}/audio/freeman/neutral.wav",
|
| 41 |
+
angry=f"{file_full_path}/audio/freeman/angry.wav",
|
| 42 |
speed=1.1,
|
| 43 |
),
|
| 44 |
Voice(
|
kitt/core/model.py
CHANGED
|
@@ -267,7 +267,7 @@ def run_inference_step(
|
|
| 267 |
# prompt += "\nThis is the first turn and you don't have <tool_results> to analyze yet."
|
| 268 |
prompt += AI_PREAMBLE
|
| 269 |
|
| 270 |
-
logger.info(f"Prompt is:\n{prompt}")
|
| 271 |
|
| 272 |
if backend == "ollama":
|
| 273 |
output = run_inference_ollama(prompt)
|
|
@@ -348,7 +348,7 @@ def run_inference_ollama(prompt):
|
|
| 348 |
def run_inference(prompt, backend="ollama"):
|
| 349 |
prompt += AI_PREAMBLE
|
| 350 |
|
| 351 |
-
logger.info(f"Prompt is:\n{prompt}")
|
| 352 |
|
| 353 |
if backend == "ollama":
|
| 354 |
output = run_inference_ollama(prompt)
|
|
|
|
| 267 |
# prompt += "\nThis is the first turn and you don't have <tool_results> to analyze yet."
|
| 268 |
prompt += AI_PREAMBLE
|
| 269 |
|
| 270 |
+
# logger.info(f"Prompt is:\n{prompt}")
|
| 271 |
|
| 272 |
if backend == "ollama":
|
| 273 |
output = run_inference_ollama(prompt)
|
|
|
|
| 348 |
def run_inference(prompt, backend="ollama"):
|
| 349 |
prompt += AI_PREAMBLE
|
| 350 |
|
| 351 |
+
# logger.info(f"Prompt is:\n{prompt}")
|
| 352 |
|
| 353 |
if backend == "ollama":
|
| 354 |
output = run_inference_ollama(prompt)
|
kitt/core/tts.py
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
|
|
| 1 |
from collections import namedtuple
|
| 2 |
|
| 3 |
import soundfile as sf
|
|
@@ -54,6 +55,15 @@ voices_replicate = [
|
|
| 54 |
]
|
| 55 |
|
| 56 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 57 |
def voice_from_text(voice, voices):
|
| 58 |
for v in voices:
|
| 59 |
if voice == f"{v.name} - Neutral":
|
|
|
|
| 1 |
+
import copy
|
| 2 |
from collections import namedtuple
|
| 3 |
|
| 4 |
import soundfile as sf
|
|
|
|
| 55 |
]
|
| 56 |
|
| 57 |
|
| 58 |
+
def prep_for_tts(text: str):
|
| 59 |
+
text_tts = copy.deepcopy(text)
|
| 60 |
+
text_tts = text_tts.replace("km/h", "kilometers per hour")
|
| 61 |
+
text_tts = text_tts.replace("°C", "degrees Celsius")
|
| 62 |
+
text_tts = text_tts.replace("°F", "degrees Fahrenheit")
|
| 63 |
+
text_tts = text_tts.replace("km", "kilometers")
|
| 64 |
+
return text_tts
|
| 65 |
+
|
| 66 |
+
|
| 67 |
def voice_from_text(voice, voices):
|
| 68 |
for v in voices:
|
| 69 |
if voice == f"{v.name} - Neutral":
|
kitt/core/utils.py
CHANGED
|
@@ -15,7 +15,7 @@ def plot_route(points, vehicle: Union[tuple[float, float], None] = None):
|
|
| 15 |
# fig = px.line_geo(lat=lats, lon=lons)
|
| 16 |
# fig.update_geos(fitbounds="locations")
|
| 17 |
|
| 18 |
-
fig = px.line_mapbox(lat=lats, lon=lons, color_discrete_sequence=["red"])
|
| 19 |
|
| 20 |
if vehicle:
|
| 21 |
fig.add_trace(
|
|
|
|
| 15 |
# fig = px.line_geo(lat=lats, lon=lons)
|
| 16 |
# fig.update_geos(fitbounds="locations")
|
| 17 |
|
| 18 |
+
fig = px.line_mapbox(lat=lats, lon=lons, color_discrete_sequence=["red"], zoom=6)
|
| 19 |
|
| 20 |
if vehicle:
|
| 21 |
fig.add_trace(
|
kitt/keepalive.py
CHANGED
|
@@ -36,7 +36,7 @@ def job():
|
|
| 36 |
|
| 37 |
logger.info("First run to boot up.")
|
| 38 |
run_replicate_model()
|
| 39 |
-
schedule.every(
|
| 40 |
logger.info("Keepalive started.")
|
| 41 |
|
| 42 |
while True:
|
|
|
|
| 36 |
|
| 37 |
logger.info("First run to boot up.")
|
| 38 |
run_replicate_model()
|
| 39 |
+
schedule.every(90).seconds.do(job)
|
| 40 |
logger.info("Keepalive started.")
|
| 41 |
|
| 42 |
while True:
|
kitt/skills/weather.py
CHANGED
|
@@ -67,8 +67,8 @@ def get_weather(location: str = "here"):
|
|
| 67 |
# Formulate the sentences - {region}, {country}
|
| 68 |
weather_sentences = (
|
| 69 |
f"The current weather in {location} is {condition_text} "
|
| 70 |
-
f"with a temperature of {temperature_c}
|
| 71 |
-
f" that feels like {feelslike_c}
|
| 72 |
if feelslike_c != temperature_c
|
| 73 |
else ""
|
| 74 |
# f"Humidity is at {humidity}%. "
|
|
@@ -132,7 +132,7 @@ def get_forecast(city_name: str = "", when=0, **kwargs):
|
|
| 132 |
number_str = f"in {when-1} days"
|
| 133 |
|
| 134 |
# Generate a sentence for the day's forecast
|
| 135 |
-
forecast_sentence = f"On {date} ({number_str}) in {city_name}, the weather will be {conditions} with a high of {max_temp_c} C and a low of {min_temp_c} C. There's a {chance_of_rain}% chance of rain. "
|
| 136 |
|
| 137 |
# number = number + 1
|
| 138 |
# Add the sentence to the result
|
|
|
|
| 67 |
# Formulate the sentences - {region}, {country}
|
| 68 |
weather_sentences = (
|
| 69 |
f"The current weather in {location} is {condition_text} "
|
| 70 |
+
f"with a temperature of {temperature_c} °C"
|
| 71 |
+
f" that feels like {feelslike_c} °C."
|
| 72 |
if feelslike_c != temperature_c
|
| 73 |
else ""
|
| 74 |
# f"Humidity is at {humidity}%. "
|
|
|
|
| 132 |
number_str = f"in {when-1} days"
|
| 133 |
|
| 134 |
# Generate a sentence for the day's forecast
|
| 135 |
+
forecast_sentence = f"On {date} ({number_str}) in {city_name}, the weather will be {conditions} with a high of {max_temp_c} °C and a low of {min_temp_c} °C. There's a {chance_of_rain}% chance of rain. "
|
| 136 |
|
| 137 |
# number = number + 1
|
| 138 |
# Add the sentence to the result
|
main.py
CHANGED
|
@@ -19,7 +19,7 @@ from kitt.core import voice_options
|
|
| 19 |
|
| 20 |
# from kitt.core.model import process_query
|
| 21 |
from kitt.core.model import generate_function_call as process_query
|
| 22 |
-
from kitt.core.tts import run_melo_tts, run_tts_fast, run_tts_replicate
|
| 23 |
from kitt.skills import (
|
| 24 |
code_interpreter,
|
| 25 |
date_time_info,
|
|
@@ -38,7 +38,7 @@ from kitt.skills import vehicle_status as vehicle_status_fn
|
|
| 38 |
from kitt.skills.common import config, vehicle
|
| 39 |
from kitt.skills.routing import calculate_route, find_address
|
| 40 |
|
| 41 |
-
ORIGIN = "
|
| 42 |
DESTINATION = "Paris, France"
|
| 43 |
DEFAULT_LLM_BACKEND = "replicate"
|
| 44 |
ENABLE_HISTORY = True
|
|
@@ -176,6 +176,7 @@ def run_generic_model(query):
|
|
| 176 |
|
| 177 |
|
| 178 |
def clear_history():
|
|
|
|
| 179 |
history.clear()
|
| 180 |
|
| 181 |
|
|
@@ -227,15 +228,16 @@ def run_llama3_model(query, voice_character, state):
|
|
| 227 |
backend=state["llm_backend"],
|
| 228 |
)
|
| 229 |
gr.Info(f"Output text: {output_text}\nGenerating voice output...")
|
|
|
|
| 230 |
voice_out = None
|
| 231 |
if global_context["tts_enabled"]:
|
| 232 |
if "Fast" in voice_character:
|
| 233 |
-
voice_out = run_melo_tts(
|
| 234 |
elif global_context["tts_backend"] == "replicate":
|
| 235 |
-
voice_out = run_tts_replicate(
|
| 236 |
else:
|
| 237 |
voice_out = tts_gradio(
|
| 238 |
-
|
| 239 |
)[0]
|
| 240 |
#
|
| 241 |
# voice_out = run_tts_fast(output_text)[0]
|
|
|
|
| 19 |
|
| 20 |
# from kitt.core.model import process_query
|
| 21 |
from kitt.core.model import generate_function_call as process_query
|
| 22 |
+
from kitt.core.tts import prep_for_tts, run_melo_tts, run_tts_fast, run_tts_replicate
|
| 23 |
from kitt.skills import (
|
| 24 |
code_interpreter,
|
| 25 |
date_time_info,
|
|
|
|
| 38 |
from kitt.skills.common import config, vehicle
|
| 39 |
from kitt.skills.routing import calculate_route, find_address
|
| 40 |
|
| 41 |
+
ORIGIN = "Luxembourg, Luxembourg"
|
| 42 |
DESTINATION = "Paris, France"
|
| 43 |
DEFAULT_LLM_BACKEND = "replicate"
|
| 44 |
ENABLE_HISTORY = True
|
|
|
|
| 176 |
|
| 177 |
|
| 178 |
def clear_history():
|
| 179 |
+
logger.info("Clearing the conversation history...")
|
| 180 |
history.clear()
|
| 181 |
|
| 182 |
|
|
|
|
| 228 |
backend=state["llm_backend"],
|
| 229 |
)
|
| 230 |
gr.Info(f"Output text: {output_text}\nGenerating voice output...")
|
| 231 |
+
output_text_tts = prep_for_tts(output_text)
|
| 232 |
voice_out = None
|
| 233 |
if global_context["tts_enabled"]:
|
| 234 |
if "Fast" in voice_character:
|
| 235 |
+
voice_out = run_melo_tts(output_text_tts, voice_character)
|
| 236 |
elif global_context["tts_backend"] == "replicate":
|
| 237 |
+
voice_out = run_tts_replicate(output_text_tts, voice_character)
|
| 238 |
else:
|
| 239 |
voice_out = tts_gradio(
|
| 240 |
+
output_text_tts, voice_character, speaker_embedding_cache
|
| 241 |
)[0]
|
| 242 |
#
|
| 243 |
# voice_out = run_tts_fast(output_text)[0]
|