{ "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 }