Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -27,9 +27,7 @@ SAMPLE_RATE = 24000
|
|
27 |
|
28 |
|
29 |
class OpenAIHandler(AsyncStreamHandler):
|
30 |
-
def __init__(
|
31 |
-
self,
|
32 |
-
) -> None:
|
33 |
super().__init__(
|
34 |
expected_layout="mono",
|
35 |
output_sample_rate=SAMPLE_RATE,
|
@@ -42,16 +40,18 @@ class OpenAIHandler(AsyncStreamHandler):
|
|
42 |
def copy(self):
|
43 |
return OpenAIHandler()
|
44 |
|
45 |
-
async def start_up(
|
46 |
-
self,
|
47 |
-
):
|
48 |
"""Connect to realtime API. Run forever in separate thread to keep connection open."""
|
49 |
self.client = openai.AsyncOpenAI()
|
50 |
async with self.client.beta.realtime.connect(
|
51 |
model="gpt-4o-mini-realtime-preview-2024-12-17"
|
52 |
) as conn:
|
|
|
53 |
await conn.session.update(
|
54 |
-
session={
|
|
|
|
|
|
|
55 |
)
|
56 |
self.connection = conn
|
57 |
async for event in self.connection:
|
|
|
27 |
|
28 |
|
29 |
class OpenAIHandler(AsyncStreamHandler):
|
30 |
+
def __init__(self) -> None:
|
|
|
|
|
31 |
super().__init__(
|
32 |
expected_layout="mono",
|
33 |
output_sample_rate=SAMPLE_RATE,
|
|
|
40 |
def copy(self):
|
41 |
return OpenAIHandler()
|
42 |
|
43 |
+
async def start_up(self):
|
|
|
|
|
44 |
"""Connect to realtime API. Run forever in separate thread to keep connection open."""
|
45 |
self.client = openai.AsyncOpenAI()
|
46 |
async with self.client.beta.realtime.connect(
|
47 |
model="gpt-4o-mini-realtime-preview-2024-12-17"
|
48 |
) as conn:
|
49 |
+
# μμ€ν
ν둬ννΈ μΆκ° λ° turn_detection μ€μ
|
50 |
await conn.session.update(
|
51 |
+
session={
|
52 |
+
"system_prompt": "λμ μ΄λ¦μ 'λΉλλννΈ'μ
λλ€. λΉμ μ λμμ΄ λλ μ 보λ₯Ό μ 곡νλ μ‘°μμ
λλ€. νμ μ ννκ³ μΉμ νκ² μλ΅νμΈμ.",
|
53 |
+
"turn_detection": {"type": "server_vad"},
|
54 |
+
}
|
55 |
)
|
56 |
self.connection = conn
|
57 |
async for event in self.connection:
|