---
title: "Pipecat પરથી ThunderPhone નો ઉપયોગ કરો"
description: "તમારા પોતાના ટ્રાન્સપોર્ટ અને ટેલિફોની સાથે, Pipecat પાઇપલાઇનમાં speech-to-speech સેવા તરીકે ThunderPhone વૉઇસ એજન્ટ ચલાવો."
---

[Pipecat](https://github.com/pipecat-ai/pipecat) એ કમ્પોઝેબલ સેવાઓમાંથી વૉઇસ એજન્ટ બનાવવા માટેનું ઓપન-સોર્સ ફ્રેમવર્ક છે. ThunderPhone **સ્પીચ-ટુ-સ્પીચ LLM સેવા** તરીકે જોડાય છે: Pipecat કૉલરનો ઑડિયો મોકલે છે, ThunderPhone એજન્ટનો અવાજ, ટ્રાન્સક્રિપ્ટ અને ફંક્શન કૉલ પરત આપે છે, અને Pipecatનું ટ્રાન્સપોર્ટ (Daily, LiveKit, Twilio, WebRTC, સ્થાનિક માઇક્રોફોન) ઑડિયો વહન કરે છે. સ્પીચ રેકગ્નિશન, ભાષા મોડેલ, અવાજ, ટર્ન-ટેકિંગ, 62 ભાષાઓ અને ટૂલ્સ બધું ThunderPhone પર ચાલે છે.

આ રીતે કરવામાં આવેલા કૉલ્સ [કૉલ ઇતિહાસ](/api-reference/calls)માં દેખાય છે અને અન્ય કોઈપણ રીઅલટાઇમ કૉલની જેમ બિલ કરવામાં આવે છે ([કિંમત](/gu/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 અથવા નવી આવૃત્તિ જરૂરી છે.

## સાચવેલ એજન્ટ ચલાવો

એજન્ટ જે કંઈ કરે છે (prompt, અવાજ, એન્જિન, ભાષાઓ, ટૂલ્સ, અભિવાદન,
મૌન ચકાસણીઓ) તે બધું ThunderPhone પર રૂપરેખાંકિત થાય છે. પાઇપલાઇન માત્ર ઑડિયો ખસેડે છે.
ડેશબોર્ડમાં એજન્ટ બનાવો અથવા Zeus (ThunderPhone એજન્ટો બનાવે, પરીક્ષણ કરે
અને ટ્યુન કરે તેવો AI એજન્ટ) પાસે તેને સેટ અપ કરાવો, પછી તેનું 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-bit મોનો PCM છે.
- વિડિયો ફ્રેમ્સ અવગણવામાં આવે છે.

<Note>
LiveKit Agents પર બિલ્ડ કરી રહ્યા છો? જુઓ
[LiveKit Agentsમાંથી ThunderPhone નો ઉપયોગ કરો](/gu/guides/use-with-livekit).
</Note>
