File size: 11,223 Bytes
5f8d57d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "!pip install google-cloud-texttospeech"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Google Cloud SDK 486.0.0\n",
      "bq 2.1.7\n",
      "core 2024.07.26\n",
      "gcloud-crc32c 1.0.0\n",
      "gsutil 5.30\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "Updates are available for some Google Cloud CLI components.  To install them,\n",
      "please run:\n",
      "  $ gcloud components update\n"
     ]
    }
   ],
   "source": [
    "!gcloud --version"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "#gcloud auth application-default login"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Your browser has been opened to visit:\n",
    "\n",
    "    https://accounts.google.com/o/oauth2/auth?response_type=code&client_id=764086051850-6qr4p6gpi6hn506pt8ejuq83di341hur.apps.googleusercontent.com&redirect_uri=http%3A%2F%2Flocalhost%3A8085%2F&scope=openid+https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fuserinfo.email+https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fcloud-platform+https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fsqlservice.login&state=rU3Hm3TBkKnist6ySUS79s8XqobXDV&access_type=offline&code_challenge=4aypyhtRgzs0m7Kdcx5q65JEeGeWz19mktZYChTEb4E&code_challenge_method=S256\n",
    "\n",
    "\n",
    "Credentials saved to file: [C:\\Users\\hari_\\AppData\\Roaming\\gcloud\\application_default_credentials.json]\n",
    "\n",
    "These credentials will be used by any library that requests Application Default Credentials (ADC).\n",
    "\n",
    "Quota project \"demoproject-111-429713\" was added to ADC which can be used by Google client libraries for billing and quota. Note that some services may still bill the project owning the resource.\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "metadata": {},
   "outputs": [],
   "source": [
    "text1 = \"\"\"\n",
    "ये वीडियो में मैंने विज्ञान भैरव पुस्तक की 112 धारणाओं को हिंदी में सिर्फ बोल के बताया है। हर एक विधि की समझ विस्तार से देखने के लिए मैंने अलग से वीडियो बनाए हैं। उसे आप देख सकते हैं मैंने विज्ञान भैरव तंत्र की।\n",
    "\n",
    "112 धारणाओं को 30 भाग में विभाजित किया है, जिसमें कर्म मार्ग के लिए आठ भाग में 31 धारणा भाव मार्ग के लिए 10 भाग में 36 धारणा और ज्ञान मार्ग के लिए 12 भाग में 45 धारणा विभाजित है। आइए।\n",
    "\n",
    "अब हर एक भाग की धारणा को संस्कृत और हिंदी में देखते हैं। भाग एक कर्ममार्ग सांस की धारणा ये भाग में कुल पांच धारणाएं हैं धारणा एक भैरव कहते हैं ऊर्जा के बनने और बिखरने के स्वभाव से ही।\n",
    "\n",
    "बाहर आता हुआ प्राण श्वास और अंदर जाता हुआ जीव श्वास निरंतर चलता रहता है। दोनों श्वास के उत्पत्ति बिंदु पर भैरव की शक्ति की भावना करने पर उसका भैरव स्वरूप प्रकट होता है। धारणा दो।\n",
    "\n",
    "अंदर आती हुई श्वास अंदर आने के बाद और बाहर जाती हुई श्वास बाहर जाने के बाद एक क्षण के लिए विलीन हो जाती है। उस मध्य स्थिति का विकास करने पर चेतना का भैरव स्वरूप प्रकाशित हो जाता है। धारणा तीन श्वास रूपी प्राण शक्ति\n",
    "\n",
    "और जीव शक्ति ना बाहर जाए ना अंदर आए उस मध्य स्थिति को विकसित करने पर साधक अपने भैरव स्वरूप को पहचान लेता है। धारणाचार, बाह्य कुंभक और अंतरकुंभक की मध्यस्थिति के विकास करने पर प्राण और अपान।\n",
    "\"\"\""
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 19,
   "metadata": {},
   "outputs": [],
   "source": [
    "output_file_name = \"vigyan_bhairav_tantra.mp3\"\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 20,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Audio content written to file vigyan_bhairav_tantra.mp3\n"
     ]
    }
   ],
   "source": [
    "import os\n",
    "from google.cloud import texttospeech\n",
    "\n",
    "# Clear any existing credentials environment variable\n",
    "if \"GOOGLE_APPLICATION_CREDENTIALS\" in os.environ:\n",
    "    del os.environ[\"GOOGLE_APPLICATION_CREDENTIALS\"]\n",
    "\n",
    "# Instantiates a client\n",
    "client = texttospeech.TextToSpeechClient()\n",
    "\n",
    "# Create the text input to be synthesized\n",
    "synthesis_input = texttospeech.SynthesisInput(text=text1)\n",
    "\n",
    "# Build the voice request\n",
    "voice = texttospeech.VoiceSelectionParams(\n",
    "    language_code=\"hi-IN\",\n",
    "    name=\"hi-IN-Wavenet-B\",  # Male voice (Wavenet offers better quality)\n",
    "    ssml_gender=texttospeech.SsmlVoiceGender.MALE\n",
    ")\n",
    "\n",
    "# Select the type of audio file\n",
    "audio_config = texttospeech.AudioConfig(\n",
    "    audio_encoding=texttospeech.AudioEncoding.MP3,\n",
    "    speaking_rate=1.0,  # 0.25 to 4.0\n",
    "    pitch=0.0,  # -20.0 to 20.0\n",
    "    volume_gain_db=0.0  # -96.0 to 16.0\n",
    ")\n",
    "\n",
    "# Perform the text-to-speech request\n",
    "response = client.synthesize_speech(\n",
    "    input=synthesis_input,\n",
    "    voice=voice,\n",
    "    audio_config=audio_config\n",
    ")\n",
    "\n",
    "# The response's audio_content is binary\n",
    "with open(output_file_name, \"wb\") as out:\n",
    "    out.write(response.audio_content)\n",
    "print(f\"Audio content written to file {output_file_name}\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 18,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Available Hindi voices:\n",
      "==================================================\n",
      "Name: hi-IN-Neural2-A\n",
      "Gender: 2\n",
      "Natural Sample Rate Hertz: 24000\n",
      "--------------------------------------------------\n",
      "Name: hi-IN-Neural2-B\n",
      "Gender: 1\n",
      "Natural Sample Rate Hertz: 24000\n",
      "--------------------------------------------------\n",
      "Name: hi-IN-Neural2-C\n",
      "Gender: 1\n",
      "Natural Sample Rate Hertz: 24000\n",
      "--------------------------------------------------\n",
      "Name: hi-IN-Neural2-D\n",
      "Gender: 2\n",
      "Natural Sample Rate Hertz: 24000\n",
      "--------------------------------------------------\n",
      "Name: hi-IN-Standard-A\n",
      "Gender: 2\n",
      "Natural Sample Rate Hertz: 24000\n",
      "--------------------------------------------------\n",
      "Name: hi-IN-Standard-B\n",
      "Gender: 1\n",
      "Natural Sample Rate Hertz: 24000\n",
      "--------------------------------------------------\n",
      "Name: hi-IN-Standard-C\n",
      "Gender: 1\n",
      "Natural Sample Rate Hertz: 24000\n",
      "--------------------------------------------------\n",
      "Name: hi-IN-Standard-D\n",
      "Gender: 2\n",
      "Natural Sample Rate Hertz: 24000\n",
      "--------------------------------------------------\n",
      "Name: hi-IN-Standard-E\n",
      "Gender: 2\n",
      "Natural Sample Rate Hertz: 24000\n",
      "--------------------------------------------------\n",
      "Name: hi-IN-Standard-F\n",
      "Gender: 1\n",
      "Natural Sample Rate Hertz: 24000\n",
      "--------------------------------------------------\n",
      "Name: hi-IN-Wavenet-A\n",
      "Gender: 2\n",
      "Natural Sample Rate Hertz: 24000\n",
      "--------------------------------------------------\n",
      "Name: hi-IN-Wavenet-B\n",
      "Gender: 1\n",
      "Natural Sample Rate Hertz: 24000\n",
      "--------------------------------------------------\n",
      "Name: hi-IN-Wavenet-C\n",
      "Gender: 1\n",
      "Natural Sample Rate Hertz: 24000\n",
      "--------------------------------------------------\n",
      "Name: hi-IN-Wavenet-D\n",
      "Gender: 2\n",
      "Natural Sample Rate Hertz: 24000\n",
      "--------------------------------------------------\n",
      "Name: hi-IN-Wavenet-E\n",
      "Gender: 2\n",
      "Natural Sample Rate Hertz: 24000\n",
      "--------------------------------------------------\n",
      "Name: hi-IN-Wavenet-F\n",
      "Gender: 1\n",
      "Natural Sample Rate Hertz: 24000\n",
      "--------------------------------------------------\n"
     ]
    }
   ],
   "source": [
    "from google.cloud import texttospeech\n",
    "\n",
    "client = texttospeech.TextToSpeechClient()\n",
    "\n",
    "# List all available voices\n",
    "voices = client.list_voices()\n",
    "\n",
    "# Filter and print Hindi voices with their details\n",
    "print(\"Available Hindi voices:\")\n",
    "print(\"=\" * 50)\n",
    "for voice in voices.voices:\n",
    "    if \"hi-IN\" in voice.language_codes:\n",
    "        print(f\"Name: {voice.name}\")\n",
    "        print(f\"Gender: {voice.ssml_gender}\")\n",
    "        print(f\"Natural Sample Rate Hertz: {voice.natural_sample_rate_hertz}\")\n",
    "        print(\"-\" * 50)"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": ".venv",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.12.4"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}