inworld: commit of original text file and changes that copy openai's with Inworld TTS as only change

This commit is contained in:
padillamt
2025-07-18 16:30:03 -07:00
parent 1bc442e329
commit 5d8c184d99
2 changed files with 127 additions and 6 deletions

View File

@@ -16,16 +16,15 @@ from pipecat.pipeline.pipeline import Pipeline
from pipecat.pipeline.runner import PipelineRunner
from pipecat.pipeline.task import PipelineParams, PipelineTask
from pipecat.processors.aggregators.openai_llm_context import OpenAILLMContext
from pipecat.services.deepgram.stt import DeepgramSTTService
from pipecat.services.openai.llm import OpenAILLMService
from pipecat.services.inworld.tts import InworldHttpTTSService
from pipecat.services.openai.llm import OpenAILLMService
from pipecat.services.openai.stt import OpenAISTTService
from pipecat.transports.base_transport import BaseTransport, TransportParams
from pipecat.transports.network.fastapi_websocket import FastAPIWebsocketParams
from pipecat.transports.services.daily import DailyParams
load_dotenv(override=True)
# We store functions so objects (e.g. SileroVADAnalyzer) don't get
# instantiated. The function will be called when the desired transport gets
# selected.
@@ -53,7 +52,11 @@ async def run_example(transport: BaseTransport, _: argparse.Namespace, handle_si
# Create an HTTP session
async with aiohttp.ClientSession() as session:
stt = DeepgramSTTService(api_key=os.getenv("DEEPGRAM_API_KEY"))
stt = OpenAISTTService(
api_key=os.getenv("OPENAI_API_KEY"),
model="gpt-4o-transcribe",
prompt="Expect words related to dogs, such as breed names.",
)
tts = InworldHttpTTSService(
api_key=os.getenv("INWORLD_API_KEY", ""),
@@ -67,7 +70,7 @@ async def run_example(transport: BaseTransport, _: argparse.Namespace, handle_si
messages = [
{
"role": "system",
"content": "You are a helpful LLM in a WebRTC call. Your goal is to demonstrate your capabilities in a succinct way. Your output will be converted to audio so don't include special characters in your answers. Respond to what the user said in a creative and helpful way.",
"content": "You are very knowledgable about dogs. Your output will be converted to audio so don't include special characters in your answers. Respond to what the user said in a creative and helpful way.",
},
]
@@ -77,7 +80,7 @@ async def run_example(transport: BaseTransport, _: argparse.Namespace, handle_si
pipeline = Pipeline(
[
transport.input(), # Transport user input
stt,
stt, # STT
context_aggregator.user(), # User responses
llm, # LLM
tts, # TTS
@@ -89,6 +92,7 @@ async def run_example(transport: BaseTransport, _: argparse.Namespace, handle_si
task = PipelineTask(
pipeline,
params=PipelineParams(
audio_out_sample_rate=24000,
enable_metrics=True,
enable_usage_metrics=True,
),