utkarshshukla2912 commited on
Commit
f4a1ce0
·
verified ·
1 Parent(s): d023303

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +32 -0
README.md CHANGED
@@ -30,6 +30,7 @@ This document explains how to call the **`generate_squirrel`** endpoint.
30
  |-----------|--------|----------|-----------------------------------------------------------------------------|
31
  | `text` | string | Yes | Text you want to synthesize. Limited to **300** characters. |
32
  | `voice_id`| string | Yes | **UUID** of the voice to use. Must match one of the IDs in the voices provided below. |
 
33
 
34
 
35
  ## 3. Example Requests
@@ -52,6 +53,37 @@ This document explains how to call the **`generate_squirrel`** endpoint.
52
  response = requests.post(url, json=payload, headers=headers)
53
 
54
  ```
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
55
 
56
  ## 4. Voices Catalogue (CSV)
57
 
 
30
  |-----------|--------|----------|-----------------------------------------------------------------------------|
31
  | `text` | string | Yes | Text you want to synthesize. Limited to **300** characters. |
32
  | `voice_id`| string | Yes | **UUID** of the voice to use. Must match one of the IDs in the voices provided below. |
33
+ | `return_raw_audio`| boolean | No **(default False)** | If the endpoint should return raw audio bytes. Guide to use the bytes as wav output is shared below |
34
 
35
 
36
  ## 3. Example Requests
 
53
  response = requests.post(url, json=payload, headers=headers)
54
 
55
  ```
56
+
57
+ **Incase someone wants to use the raw audio for realtime usecase**
58
+ ```python
59
+ import time
60
+ import wave
61
+ import requests
62
+
63
+
64
+ # Audio parameters from the API headers
65
+ sample_rate = 24000
66
+ channels = 1
67
+ sample_width = 2 # 16-bit = 2 bytes
68
+
69
+ # Save raw PCM data as WAV
70
+ def save_pcm_as_wav(pcm_bytes: bytes, output_path: str):
71
+ with wave.open(output_path, 'wb') as wav_file:
72
+ wav_file.setnchannels(channels)
73
+ wav_file.setsampwidth(sample_width)
74
+ wav_file.setframerate(sample_rate)
75
+ wav_file.writeframes(pcm_bytes)
76
+
77
+ s = time.time()
78
+ response = requests.post("https://prod-api2.desivocal.com/dv/api/v0/tts_api/generate_squirrel", json={
79
+ "text": "Hello दोस्तों! Welcome to Ringg TTS. यह एक बहुत ही शानदार text to speech system है जो Hindi और English दोनों languages को support करता है।",
80
+ "voice_id": "83ba74e4-9efb-4db3-913a-f2a0ad66904d",
81
+ "return_raw_audio": True
82
+ })
83
+
84
+ save_pcm_as_wav(response.content, "output.wav")
85
+ print(time.time()-s)
86
+ ```
87
 
88
  ## 4. Voices Catalogue (CSV)
89