---
title: "Pipecat से ThunderPhone का उपयोग करें"
description: "अपने ट्रांसपोर्ट और टेलीफोनी के साथ, Pipecat पाइपलाइन के अंदर स्पीच-टू-स्पीच सेवा के रूप में ThunderPhone वॉइस एजेंट चलाएँ।"
---

[Pipecat](https://github.com/pipecat-ai/pipecat) कंपोज़ेबल सेवाओं से वॉइस एजेंट बनाने के लिए एक ओपन-सोर्स फ्रेमवर्क है। ThunderPhone एक **स्पीच-टू-स्पीच LLM सेवा** के रूप में इंटीग्रेट होता है: Pipecat कॉलर का ऑडियो भेजता है, ThunderPhone एजेंट की आवाज़, ट्रांसक्रिप्ट और फंक्शन कॉल लौटाता है, और Pipecat का ट्रांसपोर्ट (Daily, LiveKit, Twilio, WebRTC, एक लोकल माइक्रोफ़ोन) ऑडियो को संभालता है। स्पीच रिकग्निशन, लैंग्वेज मॉडल, आवाज़, टर्न-टेकिंग, 62 भाषाएँ और टूल, सभी ThunderPhone पर चलते हैं।

इस तरह की गई कॉल [कॉल हिस्ट्री](/api-reference/calls) में दिखाई देती हैं और किसी भी अन्य रीयलटाइम कॉल की तरह बिल की जाती हैं ([मूल्य निर्धारण](/hi/guides/pricing))। इसमें कोई सब्सक्रिप्शन या ThunderPhone फ़ोन नंबर शामिल नहीं है।

## इंस्टॉल करें

```bash
pip install pipecat-thunderphone
export THUNDERPHONE_API_KEY=sk_live_...   # a secret API key
```

पैकेज Pipecat की OpenAI Realtime सेवा को रैप करता है, क्योंकि ThunderPhone का [Realtime WebSocket](/api-reference/realtime) उसी प्रोटोकॉल का उपयोग करता है। इसके लिए `pipecat-ai` 1.8 या नया संस्करण चाहिए।

## सेव किया गया एजेंट चलाएं

एजेंट जो कुछ भी करता है (प्रॉम्प्ट, वॉइस, इंजन, भाषाएं, टूल, ग्रीटिंग,
साइलेंस चेक-इन) ThunderPhone पर कॉन्फ़िगर किया जाता है। पाइपलाइन केवल ऑडियो को स्थानांतरित करती है।
डैशबोर्ड में एजेंट बनाएं, या Zeus (वह AI एजेंट जो ThunderPhone एजेंट बनाता, टेस्ट करता
और ट्यून करता है) से इसे सेट अप करवाएं, फिर यहां उसका ID पास करें। ThunderPhone पर डिप्लॉय किए गए बदलाव आपकी पाइपलाइन को छुए बिना अगली कॉल पर लागू हो जाते हैं।

```python
from pipecat.pipeline.pipeline import Pipeline
from pipecat.pipeline.worker import PipelineParams, PipelineWorker
from pipecat.processors.aggregators.llm_context import LLMContext
from pipecat.processors.aggregators.llm_response_universal import LLMContextAggregatorPair
from pipecat_thunderphone import ThunderPhoneRealtimeLLMService

llm = ThunderPhoneRealtimeLLMService(agent_id=12)

context = LLMContext()
aggregators = LLMContextAggregatorPair(context)
pipeline = Pipeline([
    transport.input(),
    aggregators.user(),
    llm,
    aggregators.assistant(),
    transport.output(),
])
worker = PipelineWorker(pipeline, params=PipelineParams(allow_interruptions=True))
```

सेव किया गया एजेंट अपने निर्धारित शेड्यूल पर कॉल शुरू करता है, इसलिए सेवा Pipecat से प्रारंभिक उत्तर का अनुरोध नहीं करती। यदि फिर भी ऐसा चाहिए, तो `greet_on_connect=True` पास करें।

## सेशन को इनलाइन कॉन्फ़िगर करें

`agent_id` के बिना, निर्देश और टूल Pipecat कॉन्टेक्स्ट से आते हैं, ठीक उसी तरह जैसे वे OpenAI के लिए आते हैं। `product` इंजन चुनता है और `voice` ThunderPhone की आवाज़ चुनता है।

```python
from pipecat.adapters.schemas.function_schema import FunctionSchema
from pipecat.adapters.schemas.tools_schema import ToolsSchema
from pipecat.services.llm_service import FunctionCallParams

llm = ThunderPhoneRealtimeLLMService(product="bolt", voice="olivia", language="es")

async def check_availability(params: FunctionCallParams):
    slots = await calendar.free_slots(params.arguments["date"])
    await params.result_callback({"slots": slots})

llm.register_function("check_availability", check_availability)

context = LLMContext(
    messages=[{"role": "system", "content": "You are Acme Dental's receptionist."}],
    tools=ToolsSchema(standard_tools=[
        FunctionSchema(
            name="check_availability",
            description="Free appointment slots on a date",
            properties={"date": {"type": "string"}},
            required=["date"],
        )
    ]),
)
```

इनलाइन सेशन क्लाइंट-नियंत्रित होते हैं: एजेंट पहले बोलता है क्योंकि कॉन्टेक्स्ट आने पर Pipecat उत्तर का अनुरोध करता है, और साइलेंस के दौरान शांत रहता है जब तक आप कोई मैसेज न जोड़ें या किसी अन्य उत्तर का अनुरोध न करें।

## विकल्प

| आर्ग्युमेंट | अर्थ |
|---|---|
| `api_key` | सीक्रेट की (`sk_live_...`)। डिफ़ॉल्ट रूप से `THUNDERPHONE_API_KEY`। |
| `agent_id` | सेव किया गया एजेंट चलाएँ। `product` और `voice` के साथ परस्पर अनन्य। |
| `product` | इनलाइन सेशंस के लिए इंजन: `bolt` (पुराने `spark` और `storm` अभी भी स्वीकार किए जाते हैं)। |
| `voice` | इनलाइन सेशंस के लिए ThunderPhone वॉइस नाम। |
| `language` | इनलाइन सेशंस के लिए प्राथमिक भाषा संकेत, उदाहरण के लिए `es`। |
| `from_number`, `to_number` | जब पाइपलाइन फ़ोन लाइन के सामने हो, तो कॉल में रिकॉर्ड करने के लिए नंबर। |
| `live_transcripts` | बोलने के दौरान कॉलर ट्रांसक्रिप्ट के अंश स्ट्रीम करें (अतिरिक्त बिलिंग)। |
| `greet_on_connect` | सेशन तैयार होते ही पहली प्रतिक्रिया का अनुरोध करें। |
| `end_task_on_call_ended` | ThunderPhone के कॉल समाप्त करने पर `EndWorkerFrame` पुश करें (डिफ़ॉल्ट रूप से चालू)। |

## इवेंट्स

ThunderPhone रियलटाइम प्रोटोकॉल के ऊपर प्लेटफ़ॉर्म इवेंट्स जोड़ता है। सर्विस
उन्हें हैंडलर्स तक पहुंचाती है:

```python
@llm.event_handler("on_call_ended")
async def on_call_ended(service, event):
    print("call ended:", event["reason"], "call id:", service.call_id)
```

सेशन लाइव होने पर `service.call_id` सेट हो जाता है। कॉल के बाद रिकॉर्डिंग,
ट्रांसक्रिप्ट और ग्रेड प्राप्त करने के लिए इसे
[`GET /v1/calls/{call_id}`](/api-reference/calls) के साथ इस्तेमाल करें।

## सीमाएं

- टर्न डिटेक्शन सर्वर-साइड है और हमेशा चालू रहता है; Pipecat-नियंत्रित टर्न्स
  (`turn_detection=False`) समर्थित नहीं हैं।
- सर्विस पर रजिस्टर किए गए फ़ंक्शन केवल इनलाइन सेशन के लिए चलते हैं। सेव किया गया
  एजेंट ThunderPhone पर अपने टूल्स चलाता है।
- ऑडियो दोनों दिशाओं में 24 kHz पर 16-बिट मोनो PCM है।
- वीडियो फ्रेम्स को अनदेखा किया जाता है।

<Note>
क्या आप LiveKit Agents पर बना रहे हैं? देखें
[LiveKit Agents से ThunderPhone इस्तेमाल करें](/hi/guides/use-with-livekit)।
</Note>
