POST
/
{guru_type}
/
text-to-speech
/
stream
/
curl --request POST \
  --url https://api.gurubase.io/api/v1/gurubase/text-to-speech/stream/ \
  --header 'x-api-key: YOUR_API_KEY' \
  --header 'Content-Type: application/json' \
  --data '{
    "text": "Hello, this is a test message with some code: `console.log(\"hello\")` and a code block:\n```python\ndef hello():\n    print(\"hello\")\n```"
  }'
{
  "msg": "No text provided"
}
Convert text to speech and stream the audio response. This endpoint processes text by replacing code blocks with “Code block” and inline code with “Inline code” before generating speech.
curl --request POST \
  --url https://api.gurubase.io/api/v1/gurubase/text-to-speech/stream/ \
  --header 'x-api-key: YOUR_API_KEY' \
  --header 'Content-Type: application/json' \
  --data '{
    "text": "Hello, this is a test message with some code: `console.log(\"hello\")` and a code block:\n```python\ndef hello():\n    print(\"hello\")\n```"
  }'

Path Parameters

guru_type
string
required
The guru type identifier for the text-to-speech request

Body Parameters

text
string
required
The text to convert to speech. Code blocks and inline code will be processed and replaced with “Code block” and “Inline code” respectively.

Response

The response is a streaming audio file in MP3 format.
audio_stream
audio/mpeg
Streaming audio response in MP3 format
{
  "msg": "No text provided"
}

Text Processing

The endpoint automatically processes text before converting to speech:
  • Code blocks: Any text wrapped in triple backticks (```) is replaced with “Code block”
  • Inline code: Any text wrapped in single backticks (`) is replaced with “Inline code”
This ensures that code syntax doesn’t interfere with speech generation and provides a better listening experience.

Streaming Response

The endpoint returns a streaming audio response with the following headers:
  • Content-Type: audio/mpeg
  • Cache-Control: no-cache
  • X-Accel-Buffering: no (disables nginx buffering for real-time streaming)