From 6ac0e8a8d767b4594ca133939f9033a3f32ec485 Mon Sep 17 00:00:00 2001 From: XuChang <757325278@qq.com> Date: Wed, 22 Jan 2025 17:39:44 +0800 Subject: [PATCH 1/3] Add environment variable loading in moondream-chatbot demo. --- examples/moondream-chatbot/server.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/examples/moondream-chatbot/server.py b/examples/moondream-chatbot/server.py index bb322ff2e..f9c8f7751 100644 --- a/examples/moondream-chatbot/server.py +++ b/examples/moondream-chatbot/server.py @@ -15,7 +15,8 @@ from fastapi.responses import JSONResponse, RedirectResponse from pipecat.transports.services.helpers.daily_rest import DailyRESTHelper, DailyRoomParams - +from dotenv import load_dotenv +load_dotenv(override=True) MAX_BOTS_PER_ROOM = 1 # Bot sub-process dict for status reporting and concurrency control From 2ecb256777e180ffb350988c087894dcdd97b0fc Mon Sep 17 00:00:00 2001 From: XuChang <757325278@qq.com> Date: Thu, 23 Jan 2025 14:26:44 +0800 Subject: [PATCH 2/3] Add environment variable loading in moondream-chatbot demo. ruff linter checked --- examples/moondream-chatbot/server.py | 9 +++++---- examples/translation-chatbot/bot.py | 12 ++++++++++++ 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/examples/moondream-chatbot/server.py b/examples/moondream-chatbot/server.py index f9c8f7751..5efd00804 100644 --- a/examples/moondream-chatbot/server.py +++ b/examples/moondream-chatbot/server.py @@ -1,4 +1,4 @@ -# +# # noqa: D100 # Copyright (c) 2024–2025, Daily # # SPDX-License-Identifier: BSD 2-Clause License @@ -10,12 +10,13 @@ from contextlib import asynccontextmanager import aiohttp +from dotenv import load_dotenv from fastapi import FastAPI, HTTPException, Request from fastapi.middleware.cors import CORSMiddleware from fastapi.responses import JSONResponse, RedirectResponse from pipecat.transports.services.helpers.daily_rest import DailyRESTHelper, DailyRoomParams -from dotenv import load_dotenv + load_dotenv(override=True) MAX_BOTS_PER_ROOM = 1 @@ -25,7 +26,7 @@ daily_helpers = {} -def cleanup(): +def cleanup(): # noqa: D103 # Clean up function, just to be extra safe for entry in bot_procs.values(): proc = entry[0] @@ -34,7 +35,7 @@ def cleanup(): @asynccontextmanager -async def lifespan(app: FastAPI): +async def lifespan(app: FastAPI): # noqa: D103 aiohttp_session = aiohttp.ClientSession() daily_helpers["rest"] = DailyRESTHelper( daily_api_key=os.getenv("DAILY_API_KEY", ""), diff --git a/examples/translation-chatbot/bot.py b/examples/translation-chatbot/bot.py index cf3d891b2..c8937abc1 100644 --- a/examples/translation-chatbot/bot.py +++ b/examples/translation-chatbot/bot.py @@ -32,6 +32,8 @@ from pipecat.processors.transcript_processor import TranscriptProcessor from pipecat.services.cartesia import CartesiaTTSService from pipecat.services.deepgram import DeepgramSTTService +from pipecat.services.azure import AzureSTTService +from pipecat.services.azure import AzureTTSService from pipecat.services.openai import OpenAILLMService from pipecat.transports.services.daily import ( DailyParams, @@ -150,6 +152,16 @@ async def main(): voice_id="34dbb662-8e98-413c-a1ef-1a3407675fe7", # Spanish Narrator Man model="sonic-multilingual", ) + # stt = AzureSTTService( + # api_key = os.getenv("AZURE_SPEECH_API_KEY"), + # region = os.getenv("AZURE_SPEECH_REGION") + # ) + # tts = AzureTTSService( + # api_key = os.getenv("AZURE_SPEECH_API_KEY"), + # region = os.getenv("AZURE_SPEECH_REGION"), + # language = "zh" + # ) + in_language = "English" out_language = "Spanish" From ddc3be84bd5fe930976289099508a0a116f6247d Mon Sep 17 00:00:00 2001 From: XuChang <757325278@qq.com> Date: Thu, 23 Jan 2025 14:28:11 +0800 Subject: [PATCH 3/3] add environment variable loading in transalation-chatbot demo. --- examples/translation-chatbot/bot.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/examples/translation-chatbot/bot.py b/examples/translation-chatbot/bot.py index c8937abc1..cf18c0a39 100644 --- a/examples/translation-chatbot/bot.py +++ b/examples/translation-chatbot/bot.py @@ -30,10 +30,9 @@ from pipecat.processors.aggregators.openai_llm_context import OpenAILLMContext from pipecat.processors.frame_processor import FrameDirection, FrameProcessor from pipecat.processors.transcript_processor import TranscriptProcessor +from pipecat.services.azure import AzureSTTService, AzureTTSService from pipecat.services.cartesia import CartesiaTTSService from pipecat.services.deepgram import DeepgramSTTService -from pipecat.services.azure import AzureSTTService -from pipecat.services.azure import AzureTTSService from pipecat.services.openai import OpenAILLMService from pipecat.transports.services.daily import ( DailyParams, @@ -162,7 +161,6 @@ async def main(): # language = "zh" # ) - in_language = "English" out_language = "Spanish"