Fix type errors in scripts and add to pyright checked set
This commit is contained in:
@@ -11,7 +11,8 @@
|
|||||||
"src/pipecat/extensions",
|
"src/pipecat/extensions",
|
||||||
"src/pipecat/turns",
|
"src/pipecat/turns",
|
||||||
"src/pipecat/pipeline",
|
"src/pipecat/pipeline",
|
||||||
"src/pipecat/runner"
|
"src/pipecat/runner",
|
||||||
|
"scripts"
|
||||||
],
|
],
|
||||||
"exclude": ["**/*_pb2.py", "**/__pycache__"],
|
"exclude": ["**/*_pb2.py", "**/__pycache__"],
|
||||||
"ignore": [
|
"ignore": [
|
||||||
@@ -24,9 +25,7 @@
|
|||||||
"src/pipecat/tests",
|
"src/pipecat/tests",
|
||||||
"src/pipecat/transports",
|
"src/pipecat/transports",
|
||||||
"src/pipecat/utils",
|
"src/pipecat/utils",
|
||||||
"tests",
|
"tests"
|
||||||
"scripts",
|
|
||||||
"docs"
|
|
||||||
],
|
],
|
||||||
"reportMissingImports": false
|
"reportMissingImports": false
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,7 +2,14 @@ import asyncio
|
|||||||
import os
|
import os
|
||||||
import signal
|
import signal
|
||||||
|
|
||||||
from daily import *
|
from daily import (
|
||||||
|
AudioData,
|
||||||
|
CallClient,
|
||||||
|
CustomAudioSource,
|
||||||
|
CustomAudioTrack,
|
||||||
|
Daily,
|
||||||
|
EventHandler,
|
||||||
|
)
|
||||||
from dotenv import load_dotenv
|
from dotenv import load_dotenv
|
||||||
from loguru import logger
|
from loguru import logger
|
||||||
|
|
||||||
@@ -33,8 +40,8 @@ class DailyProxyApp(EventHandler):
|
|||||||
def __init__(self, sample_rate: int):
|
def __init__(self, sample_rate: int):
|
||||||
super().__init__()
|
super().__init__()
|
||||||
self._sample_rate = sample_rate
|
self._sample_rate = sample_rate
|
||||||
self._loop = None
|
self._loop = asyncio.new_event_loop()
|
||||||
self._audio_queue: asyncio.Queue | None = None
|
self._audio_queue: asyncio.Queue = asyncio.Queue()
|
||||||
self._audio_task: asyncio.Task | None = None
|
self._audio_task: asyncio.Task | None = None
|
||||||
|
|
||||||
self._client: CallClient = CallClient(event_handler=self)
|
self._client: CallClient = CallClient(event_handler=self)
|
||||||
@@ -52,7 +59,6 @@ class DailyProxyApp(EventHandler):
|
|||||||
self._loop.call_soon_threadsafe(self._loop.stop)
|
self._loop.call_soon_threadsafe(self._loop.stop)
|
||||||
|
|
||||||
def run(self, meeting_url: str):
|
def run(self, meeting_url: str):
|
||||||
self._loop = asyncio.new_event_loop()
|
|
||||||
asyncio.set_event_loop(self._loop)
|
asyncio.set_event_loop(self._loop)
|
||||||
self._create_audio_task()
|
self._create_audio_task()
|
||||||
|
|
||||||
@@ -101,7 +107,6 @@ class DailyProxyApp(EventHandler):
|
|||||||
|
|
||||||
def _create_audio_task(self):
|
def _create_audio_task(self):
|
||||||
if not self._audio_task:
|
if not self._audio_task:
|
||||||
self._audio_queue = asyncio.Queue()
|
|
||||||
self._audio_task = self._loop.create_task(self._audio_task_handler())
|
self._audio_task = self._loop.create_task(self._audio_task_handler())
|
||||||
|
|
||||||
async def _cancel_audio_task(self):
|
async def _cancel_audio_task(self):
|
||||||
@@ -113,7 +118,6 @@ class DailyProxyApp(EventHandler):
|
|||||||
except asyncio.CancelledError:
|
except asyncio.CancelledError:
|
||||||
pass
|
pass
|
||||||
self._audio_task = None
|
self._audio_task = None
|
||||||
self._audio_queue = None
|
|
||||||
|
|
||||||
async def capture_participant_audio(self, participant_id: str):
|
async def capture_participant_audio(self, participant_id: str):
|
||||||
logger.info(f"Capturing participant audio: {participant_id}")
|
logger.info(f"Capturing participant audio: {participant_id}")
|
||||||
@@ -168,7 +172,7 @@ class DailyProxyApp(EventHandler):
|
|||||||
|
|
||||||
def main():
|
def main():
|
||||||
Daily.init()
|
Daily.init()
|
||||||
room_url = os.getenv("TAVUS_SAMPLE_ROOM_URL")
|
room_url = os.environ["TAVUS_SAMPLE_ROOM_URL"]
|
||||||
app = DailyProxyApp(sample_rate=24000)
|
app = DailyProxyApp(sample_rate=24000)
|
||||||
app.run(room_url)
|
app.run(room_url)
|
||||||
|
|
||||||
|
|||||||
@@ -198,7 +198,7 @@ class EvalRunner:
|
|||||||
|
|
||||||
|
|
||||||
async def run_example_pipeline(script_path: Path, eval_config: EvalConfig):
|
async def run_example_pipeline(script_path: Path, eval_config: EvalConfig):
|
||||||
room_url = os.getenv("DAILY_ROOM_URL")
|
room_url = os.environ["DAILY_ROOM_URL"]
|
||||||
|
|
||||||
module = load_module_from_path(script_path)
|
module = load_module_from_path(script_path)
|
||||||
|
|
||||||
@@ -227,7 +227,7 @@ async def run_eval_pipeline(
|
|||||||
):
|
):
|
||||||
logger.info(f"Starting eval bot")
|
logger.info(f"Starting eval bot")
|
||||||
|
|
||||||
room_url = os.getenv("DAILY_ROOM_URL")
|
room_url = os.environ["DAILY_ROOM_URL"]
|
||||||
|
|
||||||
transport = DailyTransport(
|
transport = DailyTransport(
|
||||||
room_url,
|
room_url,
|
||||||
@@ -243,7 +243,7 @@ async def run_eval_pipeline(
|
|||||||
# We disable smart formatting because some times if the user says "3 + 2 is
|
# We disable smart formatting because some times if the user says "3 + 2 is
|
||||||
# 5" (in audio) this can be converted to "32 is 5".
|
# 5" (in audio) this can be converted to "32 is 5".
|
||||||
stt = DeepgramSTTService(
|
stt = DeepgramSTTService(
|
||||||
api_key=os.getenv("DEEPGRAM_API_KEY"),
|
api_key=os.environ["DEEPGRAM_API_KEY"],
|
||||||
settings=DeepgramSTTService.Settings(
|
settings=DeepgramSTTService.Settings(
|
||||||
language="multi",
|
language="multi",
|
||||||
smart_format=False,
|
smart_format=False,
|
||||||
@@ -251,7 +251,7 @@ async def run_eval_pipeline(
|
|||||||
)
|
)
|
||||||
|
|
||||||
tts = CartesiaTTSService(
|
tts = CartesiaTTSService(
|
||||||
api_key=os.getenv("CARTESIA_API_KEY"),
|
api_key=os.environ["CARTESIA_API_KEY"],
|
||||||
settings=CartesiaTTSService.Settings(
|
settings=CartesiaTTSService.Settings(
|
||||||
voice="97f4b8fb-f2fe-444b-bb9a-c109783a857a", # Nathan
|
voice="97f4b8fb-f2fe-444b-bb9a-c109783a857a", # Nathan
|
||||||
),
|
),
|
||||||
@@ -375,7 +375,7 @@ async def run_eval_pipeline(
|
|||||||
@task.event_handler("on_pipeline_finished")
|
@task.event_handler("on_pipeline_finished")
|
||||||
async def on_pipeline_finished(task, frame):
|
async def on_pipeline_finished(task, frame):
|
||||||
if isinstance(frame, EndFrame):
|
if isinstance(frame, EndFrame):
|
||||||
await eval_runner.assert_eval(frame.reason)
|
await eval_runner.assert_eval(bool(frame.reason))
|
||||||
elif isinstance(frame, CancelFrame):
|
elif isinstance(frame, CancelFrame):
|
||||||
await eval_runner.assert_eval(False)
|
await eval_runner.assert_eval(False)
|
||||||
|
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ import sys
|
|||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
|
||||||
from dotenv import load_dotenv
|
from dotenv import load_dotenv
|
||||||
from eval import EvalRunner
|
from eval import EvalConfig, EvalRunner
|
||||||
from loguru import logger
|
from loguru import logger
|
||||||
from utils import check_env_variables
|
from utils import check_env_variables
|
||||||
|
|
||||||
@@ -33,7 +33,8 @@ async def main(args: argparse.Namespace):
|
|||||||
|
|
||||||
runner = EvalRunner(examples_dir=script_path, record_audio=args.audio, log_level=log_level)
|
runner = EvalRunner(examples_dir=script_path, record_audio=args.audio, log_level=log_level)
|
||||||
|
|
||||||
await runner.run_eval(script_file, args.prompt, args.eval)
|
eval_config = EvalConfig(prompt=args.prompt, eval=args.eval)
|
||||||
|
await runner.run_eval(script_file, eval_config)
|
||||||
|
|
||||||
runner.print_results()
|
runner.print_results()
|
||||||
|
|
||||||
|
|||||||
@@ -79,6 +79,8 @@ def load_module_from_path(path: str | Path):
|
|||||||
module_name = path.stem
|
module_name = path.stem
|
||||||
|
|
||||||
spec = importlib.util.spec_from_file_location(module_name, str(path))
|
spec = importlib.util.spec_from_file_location(module_name, str(path))
|
||||||
|
if spec is None or spec.loader is None:
|
||||||
|
raise ImportError(f"Could not load module spec from {path}")
|
||||||
module = importlib.util.module_from_spec(spec)
|
module = importlib.util.module_from_spec(spec)
|
||||||
spec.loader.exec_module(module)
|
spec.loader.exec_module(module)
|
||||||
return module
|
return module
|
||||||
|
|||||||
@@ -71,7 +71,7 @@ async def analyze_audio_file(
|
|||||||
frame_duration_ms: int = 20,
|
frame_duration_ms: int = 20,
|
||||||
chunk_duration_ms: int = 20,
|
chunk_duration_ms: int = 20,
|
||||||
verbose: bool = False,
|
verbose: bool = False,
|
||||||
output_file: str = None,
|
output_file: str | None = None,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Analyze an audio file for turn detection using Krisp VIVA turn analyzer.
|
"""Analyze an audio file for turn detection using Krisp VIVA turn analyzer.
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user