Spaces:
Sleeping
Sleeping
Commit
·
5f8d57d
0
Parent(s):
first commit
Browse files- .gitignore +171 -0
- create_vector_db.py +86 -0
- query_vector_db.py +41 -0
- requirements.txt +6 -0
- src/speech-to-text/speech-to-text.ipynb +271 -0
- src/speech-to-text/vigyan_bhairav_tantra.mp3 +0 -0
.gitignore
ADDED
@@ -0,0 +1,171 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# I am keeping unzipped data from downloaded file, so no sending to github again.
|
2 |
+
tempdata/
|
3 |
+
|
4 |
+
vector_db/
|
5 |
+
|
6 |
+
# Byte-compiled / optimized / DLL files
|
7 |
+
__pycache__/
|
8 |
+
*.py[cod]
|
9 |
+
*$py.class
|
10 |
+
|
11 |
+
# C extensions
|
12 |
+
*.so
|
13 |
+
|
14 |
+
# Distribution / packaging
|
15 |
+
.Python
|
16 |
+
build/
|
17 |
+
develop-eggs/
|
18 |
+
dist/
|
19 |
+
downloads/
|
20 |
+
eggs/
|
21 |
+
.eggs/
|
22 |
+
lib/
|
23 |
+
lib64/
|
24 |
+
parts/
|
25 |
+
sdist/
|
26 |
+
var/
|
27 |
+
wheels/
|
28 |
+
share/python-wheels/
|
29 |
+
*.egg-info/
|
30 |
+
.installed.cfg
|
31 |
+
*.egg
|
32 |
+
MANIFEST
|
33 |
+
|
34 |
+
# Big files
|
35 |
+
*.zip
|
36 |
+
*.pt
|
37 |
+
*.pptx
|
38 |
+
|
39 |
+
|
40 |
+
# PyInstaller
|
41 |
+
# Usually these files are written by a python script from a template
|
42 |
+
# before PyInstaller builds the exe, so as to inject date/other infos into it.
|
43 |
+
*.manifest
|
44 |
+
*.spec
|
45 |
+
|
46 |
+
# Installer logs
|
47 |
+
pip-log.txt
|
48 |
+
pip-delete-this-directory.txt
|
49 |
+
|
50 |
+
# Unit test / coverage reports
|
51 |
+
htmlcov/
|
52 |
+
.tox/
|
53 |
+
.nox/
|
54 |
+
.coverage
|
55 |
+
.coverage.*
|
56 |
+
.cache
|
57 |
+
nosetests.xml
|
58 |
+
coverage.xml
|
59 |
+
*.cover
|
60 |
+
*.py,cover
|
61 |
+
.hypothesis/
|
62 |
+
.pytest_cache/
|
63 |
+
cover/
|
64 |
+
|
65 |
+
# Translations
|
66 |
+
*.mo
|
67 |
+
*.pot
|
68 |
+
|
69 |
+
# Django stuff:
|
70 |
+
*.log
|
71 |
+
local_settings.py
|
72 |
+
db.sqlite3
|
73 |
+
db.sqlite3-journal
|
74 |
+
|
75 |
+
# Flask stuff:
|
76 |
+
instance/
|
77 |
+
.webassets-cache
|
78 |
+
|
79 |
+
# Scrapy stuff:
|
80 |
+
.scrapy
|
81 |
+
|
82 |
+
# Sphinx documentation
|
83 |
+
docs/_build/
|
84 |
+
|
85 |
+
# PyBuilder
|
86 |
+
.pybuilder/
|
87 |
+
target/
|
88 |
+
|
89 |
+
# Jupyter Notebook
|
90 |
+
.ipynb_checkpoints
|
91 |
+
|
92 |
+
# IPython
|
93 |
+
profile_default/
|
94 |
+
ipython_config.py
|
95 |
+
|
96 |
+
# pyenv
|
97 |
+
# For a library or package, you might want to ignore these files since the code is
|
98 |
+
# intended to run in multiple environments; otherwise, check them in:
|
99 |
+
# .python-version
|
100 |
+
|
101 |
+
# pipenv
|
102 |
+
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
|
103 |
+
# However, in case of collaboration, if having platform-specific dependencies or dependencies
|
104 |
+
# having no cross-platform support, pipenv may install dependencies that don't work, or not
|
105 |
+
# install all needed dependencies.
|
106 |
+
#Pipfile.lock
|
107 |
+
|
108 |
+
# poetry
|
109 |
+
# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
|
110 |
+
# This is especially recommended for binary packages to ensure reproducibility, and is more
|
111 |
+
# commonly ignored for libraries.
|
112 |
+
# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
|
113 |
+
#poetry.lock
|
114 |
+
|
115 |
+
# pdm
|
116 |
+
# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
|
117 |
+
#pdm.lock
|
118 |
+
# pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it
|
119 |
+
# in version control.
|
120 |
+
# https://pdm.fming.dev/#use-with-ide
|
121 |
+
.pdm.toml
|
122 |
+
|
123 |
+
# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
|
124 |
+
__pypackages__/
|
125 |
+
|
126 |
+
# Celery stuff
|
127 |
+
celerybeat-schedule
|
128 |
+
celerybeat.pid
|
129 |
+
|
130 |
+
# SageMath parsed files
|
131 |
+
*.sage.py
|
132 |
+
|
133 |
+
# Environments
|
134 |
+
.env
|
135 |
+
.venv
|
136 |
+
env/
|
137 |
+
venv/
|
138 |
+
ENV/
|
139 |
+
env.bak/
|
140 |
+
venv.bak/
|
141 |
+
|
142 |
+
# Spyder project settings
|
143 |
+
.spyderproject
|
144 |
+
.spyproject
|
145 |
+
|
146 |
+
# Rope project settings
|
147 |
+
.ropeproject
|
148 |
+
|
149 |
+
# mkdocs documentation
|
150 |
+
/site
|
151 |
+
|
152 |
+
# mypy
|
153 |
+
.mypy_cache/
|
154 |
+
.dmypy.json
|
155 |
+
dmypy.json
|
156 |
+
|
157 |
+
# Pyre type checker
|
158 |
+
.pyre/
|
159 |
+
|
160 |
+
# pytype static type analyzer
|
161 |
+
.pytype/
|
162 |
+
|
163 |
+
# Cython debug symbols
|
164 |
+
cython_debug/
|
165 |
+
|
166 |
+
# PyCharm
|
167 |
+
# JetBrains specific template is maintained in a separate JetBrains.gitignore that can
|
168 |
+
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
|
169 |
+
# and can be added to the global gitignore or merged into this file. For a more nuclear
|
170 |
+
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
|
171 |
+
#.idea/
|
create_vector_db.py
ADDED
@@ -0,0 +1,86 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import os
|
2 |
+
from typing import List, Dict
|
3 |
+
import PyPDF2
|
4 |
+
from langchain.text_splitter import RecursiveCharacterTextSplitter
|
5 |
+
import chromadb
|
6 |
+
from chromadb.utils import embedding_functions
|
7 |
+
from tqdm import tqdm
|
8 |
+
|
9 |
+
class PDFVectorizer:
|
10 |
+
def __init__(self, pdf_dir: str, db_dir: str):
|
11 |
+
self.pdf_dir = pdf_dir
|
12 |
+
self.db_dir = db_dir
|
13 |
+
self.text_splitter = RecursiveCharacterTextSplitter(
|
14 |
+
chunk_size=1000,
|
15 |
+
chunk_overlap=200,
|
16 |
+
length_function=len
|
17 |
+
)
|
18 |
+
# Initialize ChromaDB with sentence-transformers embeddings
|
19 |
+
self.client = chromadb.PersistentClient(path=db_dir)
|
20 |
+
self.embedding_function = embedding_functions.SentenceTransformerEmbeddingFunction(
|
21 |
+
model_name="all-MiniLM-L6-v2"
|
22 |
+
)
|
23 |
+
self.collection = self.client.create_collection(
|
24 |
+
name="osho_books",
|
25 |
+
embedding_function=self.embedding_function
|
26 |
+
)
|
27 |
+
|
28 |
+
def extract_text_from_pdf(self, pdf_path: str) -> str:
|
29 |
+
"""Extract text from a PDF file."""
|
30 |
+
try:
|
31 |
+
with open(pdf_path, 'rb') as file:
|
32 |
+
reader = PyPDF2.PdfReader(file)
|
33 |
+
text = ""
|
34 |
+
for page in reader.pages:
|
35 |
+
text += page.extract_text() + "\n"
|
36 |
+
return text
|
37 |
+
except Exception as e:
|
38 |
+
print(f"Error processing {pdf_path}: {str(e)}")
|
39 |
+
return ""
|
40 |
+
|
41 |
+
def process_pdf(self, pdf_path: str) -> List[Dict]:
|
42 |
+
"""Process a single PDF file and return chunks with metadata."""
|
43 |
+
text = self.extract_text_from_pdf(pdf_path)
|
44 |
+
if not text:
|
45 |
+
return []
|
46 |
+
|
47 |
+
chunks = self.text_splitter.split_text(text)
|
48 |
+
book_name = os.path.basename(pdf_path)
|
49 |
+
|
50 |
+
return [{
|
51 |
+
"text": chunk,
|
52 |
+
"metadata": {
|
53 |
+
"book": book_name,
|
54 |
+
"chunk_index": i
|
55 |
+
}
|
56 |
+
} for i, chunk in enumerate(chunks)]
|
57 |
+
|
58 |
+
def create_vector_database(self):
|
59 |
+
"""Process all PDFs and create the vector database."""
|
60 |
+
pdf_files = [f for f in os.listdir(self.pdf_dir) if f.endswith('.pdf')]
|
61 |
+
|
62 |
+
for pdf_file in tqdm(pdf_files, desc="Processing PDFs"):
|
63 |
+
pdf_path = os.path.join(self.pdf_dir, pdf_file)
|
64 |
+
chunks = self.process_pdf(pdf_path)
|
65 |
+
|
66 |
+
if chunks:
|
67 |
+
# Add chunks to ChromaDB
|
68 |
+
self.collection.add(
|
69 |
+
documents=[chunk["text"] for chunk in chunks],
|
70 |
+
metadatas=[chunk["metadata"] for chunk in chunks],
|
71 |
+
ids=[f"{pdf_file}_{chunk['metadata']['chunk_index']}" for chunk in chunks]
|
72 |
+
)
|
73 |
+
print(f"Added {len(chunks)} chunks from {pdf_file}")
|
74 |
+
|
75 |
+
if __name__ == "__main__":
|
76 |
+
# Define directories
|
77 |
+
pdf_dir = os.path.join(os.getcwd(), "OshoBooks")
|
78 |
+
db_dir = os.path.join(os.getcwd(), "vector_db")
|
79 |
+
|
80 |
+
# Create vector database directory if it doesn't exist
|
81 |
+
os.makedirs(db_dir, exist_ok=True)
|
82 |
+
|
83 |
+
# Initialize and run the vectorizer
|
84 |
+
vectorizer = PDFVectorizer(pdf_dir, db_dir)
|
85 |
+
vectorizer.create_vector_database()
|
86 |
+
print("Vector database creation completed!")
|
query_vector_db.py
ADDED
@@ -0,0 +1,41 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import os
|
2 |
+
import chromadb
|
3 |
+
from chromadb.utils import embedding_functions
|
4 |
+
|
5 |
+
def query_vector_db(query: str, n_results: int = 5):
|
6 |
+
"""Query the vector database and return relevant passages."""
|
7 |
+
# Initialize ChromaDB client
|
8 |
+
db_dir = os.path.join(os.getcwd(), "vector_db")
|
9 |
+
client = chromadb.PersistentClient(path=db_dir)
|
10 |
+
|
11 |
+
# Initialize embedding function (same as used in creation)
|
12 |
+
embedding_function = embedding_functions.SentenceTransformerEmbeddingFunction(
|
13 |
+
model_name="all-MiniLM-L6-v2"
|
14 |
+
)
|
15 |
+
|
16 |
+
# Get the collection
|
17 |
+
collection = client.get_collection(
|
18 |
+
name="osho_books",
|
19 |
+
embedding_function=embedding_function
|
20 |
+
)
|
21 |
+
|
22 |
+
# Query the collection
|
23 |
+
results = collection.query(
|
24 |
+
query_texts=[query],
|
25 |
+
n_results=n_results
|
26 |
+
)
|
27 |
+
|
28 |
+
# Print results
|
29 |
+
print(f"\nQuery: {query}\n")
|
30 |
+
for i, (doc, metadata) in enumerate(zip(results['documents'][0], results['metadatas'][0])):
|
31 |
+
print(f"\nResult {i+1}:")
|
32 |
+
print(f"Book: {metadata['book']}")
|
33 |
+
print(f"Passage: {doc[:200]}...") # Show first 200 characters
|
34 |
+
print("-" * 80)
|
35 |
+
|
36 |
+
if __name__ == "__main__":
|
37 |
+
while True:
|
38 |
+
query = input("\nEnter your query (or 'quit' to exit): ")
|
39 |
+
if query.lower() == 'quit':
|
40 |
+
break
|
41 |
+
query_vector_db(query)
|
requirements.txt
ADDED
@@ -0,0 +1,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
PyPDF2==3.0.1
|
2 |
+
langchain==0.0.350
|
3 |
+
chromadb==0.4.20
|
4 |
+
sentence-transformers==2.2.2
|
5 |
+
tqdm==4.66.1
|
6 |
+
huggingface-hub==0.19.4
|
src/speech-to-text/speech-to-text.ipynb
ADDED
@@ -0,0 +1,271 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"cells": [
|
3 |
+
{
|
4 |
+
"cell_type": "code",
|
5 |
+
"execution_count": null,
|
6 |
+
"metadata": {},
|
7 |
+
"outputs": [],
|
8 |
+
"source": [
|
9 |
+
"!pip install google-cloud-texttospeech"
|
10 |
+
]
|
11 |
+
},
|
12 |
+
{
|
13 |
+
"cell_type": "code",
|
14 |
+
"execution_count": 12,
|
15 |
+
"metadata": {},
|
16 |
+
"outputs": [
|
17 |
+
{
|
18 |
+
"name": "stdout",
|
19 |
+
"output_type": "stream",
|
20 |
+
"text": [
|
21 |
+
"Google Cloud SDK 486.0.0\n",
|
22 |
+
"bq 2.1.7\n",
|
23 |
+
"core 2024.07.26\n",
|
24 |
+
"gcloud-crc32c 1.0.0\n",
|
25 |
+
"gsutil 5.30\n"
|
26 |
+
]
|
27 |
+
},
|
28 |
+
{
|
29 |
+
"name": "stderr",
|
30 |
+
"output_type": "stream",
|
31 |
+
"text": [
|
32 |
+
"Updates are available for some Google Cloud CLI components. To install them,\n",
|
33 |
+
"please run:\n",
|
34 |
+
" $ gcloud components update\n"
|
35 |
+
]
|
36 |
+
}
|
37 |
+
],
|
38 |
+
"source": [
|
39 |
+
"!gcloud --version"
|
40 |
+
]
|
41 |
+
},
|
42 |
+
{
|
43 |
+
"cell_type": "code",
|
44 |
+
"execution_count": null,
|
45 |
+
"metadata": {},
|
46 |
+
"outputs": [],
|
47 |
+
"source": [
|
48 |
+
"#gcloud auth application-default login"
|
49 |
+
]
|
50 |
+
},
|
51 |
+
{
|
52 |
+
"cell_type": "markdown",
|
53 |
+
"metadata": {},
|
54 |
+
"source": [
|
55 |
+
"Your browser has been opened to visit:\n",
|
56 |
+
"\n",
|
57 |
+
" 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",
|
58 |
+
"\n",
|
59 |
+
"\n",
|
60 |
+
"Credentials saved to file: [C:\\Users\\hari_\\AppData\\Roaming\\gcloud\\application_default_credentials.json]\n",
|
61 |
+
"\n",
|
62 |
+
"These credentials will be used by any library that requests Application Default Credentials (ADC).\n",
|
63 |
+
"\n",
|
64 |
+
"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"
|
65 |
+
]
|
66 |
+
},
|
67 |
+
{
|
68 |
+
"cell_type": "code",
|
69 |
+
"execution_count": 17,
|
70 |
+
"metadata": {},
|
71 |
+
"outputs": [],
|
72 |
+
"source": [
|
73 |
+
"text1 = \"\"\"\n",
|
74 |
+
"ये वीडियो में मैंने विज्ञान भैरव पुस्तक की 112 धारणाओं को हिंदी में सिर्फ बोल के बताया है। हर एक विधि की समझ विस्तार से देखने के लिए मैंने अलग से वीडियो बनाए हैं। उसे आप देख सकते हैं मैंने विज्ञान भैरव तंत्र की।\n",
|
75 |
+
"\n",
|
76 |
+
"112 धारणाओं को 30 भाग में विभाजित किया है, जिसमें कर्म मार्ग के लिए आठ भाग में 31 धारणा भाव मार्ग के लिए 10 भाग में 36 धारणा और ज्ञान मार्ग के लिए 12 भाग में 45 धारणा विभाजित है। आइए।\n",
|
77 |
+
"\n",
|
78 |
+
"अब हर एक भाग की धारणा को संस्कृत और हिंदी में देखते हैं। भाग एक कर्ममार्ग सांस की धारणा ये भाग में कुल पांच धारणाएं हैं धारणा एक भैरव कहते हैं ऊर्जा के बनने और बिखरने के स्वभाव से ही।\n",
|
79 |
+
"\n",
|
80 |
+
"बाहर आता हुआ प्राण श्वास और अंदर जाता हुआ जीव श्वास निरंतर चलता रहता है। दोनों श्वास के उत्पत्ति बिंदु पर भैरव की शक्ति की भावना करने पर उसका भैरव स्वरूप प्रकट होता है। धारणा दो।\n",
|
81 |
+
"\n",
|
82 |
+
"अंदर आती हुई श्वास अंदर आने के बाद और बाहर जाती हुई श्वास बाहर जाने के बाद एक क्षण के लिए विलीन हो जाती है। उस मध्य स्थिति का विकास करने पर चेतना का भैरव स्वरूप प्रकाशित हो जाता है। धारणा तीन श्वास रूपी प्राण शक्ति\n",
|
83 |
+
"\n",
|
84 |
+
"और जीव शक्ति ना बाहर जाए ना अंदर आए उस मध्य स्थिति को विकसित करने पर साधक अपने भैरव स्वरूप को पहचान लेता है। धारणाचार, बाह्य कुंभक और अंतरकुंभक की मध्यस्थिति के विकास करने पर प्राण और अपान।\n",
|
85 |
+
"\"\"\""
|
86 |
+
]
|
87 |
+
},
|
88 |
+
{
|
89 |
+
"cell_type": "code",
|
90 |
+
"execution_count": 19,
|
91 |
+
"metadata": {},
|
92 |
+
"outputs": [],
|
93 |
+
"source": [
|
94 |
+
"output_file_name = \"vigyan_bhairav_tantra.mp3\"\n"
|
95 |
+
]
|
96 |
+
},
|
97 |
+
{
|
98 |
+
"cell_type": "code",
|
99 |
+
"execution_count": 20,
|
100 |
+
"metadata": {},
|
101 |
+
"outputs": [
|
102 |
+
{
|
103 |
+
"name": "stdout",
|
104 |
+
"output_type": "stream",
|
105 |
+
"text": [
|
106 |
+
"Audio content written to file vigyan_bhairav_tantra.mp3\n"
|
107 |
+
]
|
108 |
+
}
|
109 |
+
],
|
110 |
+
"source": [
|
111 |
+
"import os\n",
|
112 |
+
"from google.cloud import texttospeech\n",
|
113 |
+
"\n",
|
114 |
+
"# Clear any existing credentials environment variable\n",
|
115 |
+
"if \"GOOGLE_APPLICATION_CREDENTIALS\" in os.environ:\n",
|
116 |
+
" del os.environ[\"GOOGLE_APPLICATION_CREDENTIALS\"]\n",
|
117 |
+
"\n",
|
118 |
+
"# Instantiates a client\n",
|
119 |
+
"client = texttospeech.TextToSpeechClient()\n",
|
120 |
+
"\n",
|
121 |
+
"# Create the text input to be synthesized\n",
|
122 |
+
"synthesis_input = texttospeech.SynthesisInput(text=text1)\n",
|
123 |
+
"\n",
|
124 |
+
"# Build the voice request\n",
|
125 |
+
"voice = texttospeech.VoiceSelectionParams(\n",
|
126 |
+
" language_code=\"hi-IN\",\n",
|
127 |
+
" name=\"hi-IN-Wavenet-B\", # Male voice (Wavenet offers better quality)\n",
|
128 |
+
" ssml_gender=texttospeech.SsmlVoiceGender.MALE\n",
|
129 |
+
")\n",
|
130 |
+
"\n",
|
131 |
+
"# Select the type of audio file\n",
|
132 |
+
"audio_config = texttospeech.AudioConfig(\n",
|
133 |
+
" audio_encoding=texttospeech.AudioEncoding.MP3,\n",
|
134 |
+
" speaking_rate=1.0, # 0.25 to 4.0\n",
|
135 |
+
" pitch=0.0, # -20.0 to 20.0\n",
|
136 |
+
" volume_gain_db=0.0 # -96.0 to 16.0\n",
|
137 |
+
")\n",
|
138 |
+
"\n",
|
139 |
+
"# Perform the text-to-speech request\n",
|
140 |
+
"response = client.synthesize_speech(\n",
|
141 |
+
" input=synthesis_input,\n",
|
142 |
+
" voice=voice,\n",
|
143 |
+
" audio_config=audio_config\n",
|
144 |
+
")\n",
|
145 |
+
"\n",
|
146 |
+
"# The response's audio_content is binary\n",
|
147 |
+
"with open(output_file_name, \"wb\") as out:\n",
|
148 |
+
" out.write(response.audio_content)\n",
|
149 |
+
"print(f\"Audio content written to file {output_file_name}\")"
|
150 |
+
]
|
151 |
+
},
|
152 |
+
{
|
153 |
+
"cell_type": "code",
|
154 |
+
"execution_count": 18,
|
155 |
+
"metadata": {},
|
156 |
+
"outputs": [
|
157 |
+
{
|
158 |
+
"name": "stdout",
|
159 |
+
"output_type": "stream",
|
160 |
+
"text": [
|
161 |
+
"Available Hindi voices:\n",
|
162 |
+
"==================================================\n",
|
163 |
+
"Name: hi-IN-Neural2-A\n",
|
164 |
+
"Gender: 2\n",
|
165 |
+
"Natural Sample Rate Hertz: 24000\n",
|
166 |
+
"--------------------------------------------------\n",
|
167 |
+
"Name: hi-IN-Neural2-B\n",
|
168 |
+
"Gender: 1\n",
|
169 |
+
"Natural Sample Rate Hertz: 24000\n",
|
170 |
+
"--------------------------------------------------\n",
|
171 |
+
"Name: hi-IN-Neural2-C\n",
|
172 |
+
"Gender: 1\n",
|
173 |
+
"Natural Sample Rate Hertz: 24000\n",
|
174 |
+
"--------------------------------------------------\n",
|
175 |
+
"Name: hi-IN-Neural2-D\n",
|
176 |
+
"Gender: 2\n",
|
177 |
+
"Natural Sample Rate Hertz: 24000\n",
|
178 |
+
"--------------------------------------------------\n",
|
179 |
+
"Name: hi-IN-Standard-A\n",
|
180 |
+
"Gender: 2\n",
|
181 |
+
"Natural Sample Rate Hertz: 24000\n",
|
182 |
+
"--------------------------------------------------\n",
|
183 |
+
"Name: hi-IN-Standard-B\n",
|
184 |
+
"Gender: 1\n",
|
185 |
+
"Natural Sample Rate Hertz: 24000\n",
|
186 |
+
"--------------------------------------------------\n",
|
187 |
+
"Name: hi-IN-Standard-C\n",
|
188 |
+
"Gender: 1\n",
|
189 |
+
"Natural Sample Rate Hertz: 24000\n",
|
190 |
+
"--------------------------------------------------\n",
|
191 |
+
"Name: hi-IN-Standard-D\n",
|
192 |
+
"Gender: 2\n",
|
193 |
+
"Natural Sample Rate Hertz: 24000\n",
|
194 |
+
"--------------------------------------------------\n",
|
195 |
+
"Name: hi-IN-Standard-E\n",
|
196 |
+
"Gender: 2\n",
|
197 |
+
"Natural Sample Rate Hertz: 24000\n",
|
198 |
+
"--------------------------------------------------\n",
|
199 |
+
"Name: hi-IN-Standard-F\n",
|
200 |
+
"Gender: 1\n",
|
201 |
+
"Natural Sample Rate Hertz: 24000\n",
|
202 |
+
"--------------------------------------------------\n",
|
203 |
+
"Name: hi-IN-Wavenet-A\n",
|
204 |
+
"Gender: 2\n",
|
205 |
+
"Natural Sample Rate Hertz: 24000\n",
|
206 |
+
"--------------------------------------------------\n",
|
207 |
+
"Name: hi-IN-Wavenet-B\n",
|
208 |
+
"Gender: 1\n",
|
209 |
+
"Natural Sample Rate Hertz: 24000\n",
|
210 |
+
"--------------------------------------------------\n",
|
211 |
+
"Name: hi-IN-Wavenet-C\n",
|
212 |
+
"Gender: 1\n",
|
213 |
+
"Natural Sample Rate Hertz: 24000\n",
|
214 |
+
"--------------------------------------------------\n",
|
215 |
+
"Name: hi-IN-Wavenet-D\n",
|
216 |
+
"Gender: 2\n",
|
217 |
+
"Natural Sample Rate Hertz: 24000\n",
|
218 |
+
"--------------------------------------------------\n",
|
219 |
+
"Name: hi-IN-Wavenet-E\n",
|
220 |
+
"Gender: 2\n",
|
221 |
+
"Natural Sample Rate Hertz: 24000\n",
|
222 |
+
"--------------------------------------------------\n",
|
223 |
+
"Name: hi-IN-Wavenet-F\n",
|
224 |
+
"Gender: 1\n",
|
225 |
+
"Natural Sample Rate Hertz: 24000\n",
|
226 |
+
"--------------------------------------------------\n"
|
227 |
+
]
|
228 |
+
}
|
229 |
+
],
|
230 |
+
"source": [
|
231 |
+
"from google.cloud import texttospeech\n",
|
232 |
+
"\n",
|
233 |
+
"client = texttospeech.TextToSpeechClient()\n",
|
234 |
+
"\n",
|
235 |
+
"# List all available voices\n",
|
236 |
+
"voices = client.list_voices()\n",
|
237 |
+
"\n",
|
238 |
+
"# Filter and print Hindi voices with their details\n",
|
239 |
+
"print(\"Available Hindi voices:\")\n",
|
240 |
+
"print(\"=\" * 50)\n",
|
241 |
+
"for voice in voices.voices:\n",
|
242 |
+
" if \"hi-IN\" in voice.language_codes:\n",
|
243 |
+
" print(f\"Name: {voice.name}\")\n",
|
244 |
+
" print(f\"Gender: {voice.ssml_gender}\")\n",
|
245 |
+
" print(f\"Natural Sample Rate Hertz: {voice.natural_sample_rate_hertz}\")\n",
|
246 |
+
" print(\"-\" * 50)"
|
247 |
+
]
|
248 |
+
}
|
249 |
+
],
|
250 |
+
"metadata": {
|
251 |
+
"kernelspec": {
|
252 |
+
"display_name": ".venv",
|
253 |
+
"language": "python",
|
254 |
+
"name": "python3"
|
255 |
+
},
|
256 |
+
"language_info": {
|
257 |
+
"codemirror_mode": {
|
258 |
+
"name": "ipython",
|
259 |
+
"version": 3
|
260 |
+
},
|
261 |
+
"file_extension": ".py",
|
262 |
+
"mimetype": "text/x-python",
|
263 |
+
"name": "python",
|
264 |
+
"nbconvert_exporter": "python",
|
265 |
+
"pygments_lexer": "ipython3",
|
266 |
+
"version": "3.12.4"
|
267 |
+
}
|
268 |
+
},
|
269 |
+
"nbformat": 4,
|
270 |
+
"nbformat_minor": 2
|
271 |
+
}
|
src/speech-to-text/vigyan_bhairav_tantra.mp3
ADDED
Binary file (601 kB). View file
|
|