backend00300 0.1.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- backend00300-0.1.0/PKG-INFO +12 -0
- backend00300-0.1.0/backend00300/__init__.py +123 -0
- backend00300-0.1.0/backend00300.egg-info/PKG-INFO +12 -0
- backend00300-0.1.0/backend00300.egg-info/SOURCES.txt +7 -0
- backend00300-0.1.0/backend00300.egg-info/dependency_links.txt +1 -0
- backend00300-0.1.0/backend00300.egg-info/requires.txt +2 -0
- backend00300-0.1.0/backend00300.egg-info/top_level.txt +1 -0
- backend00300-0.1.0/setup.cfg +4 -0
- backend00300-0.1.0/setup.py +16 -0
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
Metadata-Version: 2.1
|
|
2
|
+
Name: backend00300
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: This is speech to text package created by Manas Singh Rajput
|
|
5
|
+
Home-page: UNKNOWN
|
|
6
|
+
Author: Manas Singh Rajput
|
|
7
|
+
Author-email: singmanassingh123456789@gmail.com, veerendrapratapsingh804@gmail.com
|
|
8
|
+
License: UNKNOWN
|
|
9
|
+
Platform: UNKNOWN
|
|
10
|
+
|
|
11
|
+
UNKNOWN
|
|
12
|
+
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
from selenium import webdriver
|
|
2
|
+
from selenium.webdriver.common.by import By
|
|
3
|
+
from selenium.webdriver.support.ui import WebDriverWait
|
|
4
|
+
from selenium.webdriver.support import expected_conditions as EC
|
|
5
|
+
from selenium.webdriver.chrome.service import Service
|
|
6
|
+
from webdriver_manager.chrome import ChromeDriverManager
|
|
7
|
+
from os import getcwd
|
|
8
|
+
from pathlib import Path
|
|
9
|
+
from shutil import which
|
|
10
|
+
import sys
|
|
11
|
+
|
|
12
|
+
chrome_option = webdriver.ChromeOptions()
|
|
13
|
+
chrome_option.add_argument("--use-fake-ui-for-media-stream")
|
|
14
|
+
chrome_option.add_argument("--no-sandbox")
|
|
15
|
+
chrome_option.add_argument("--disable-dev-shm-usage")
|
|
16
|
+
# Live mic generally fails in headless mode.
|
|
17
|
+
# chrome_option.add_argument("--headless=new")
|
|
18
|
+
|
|
19
|
+
chrome_bin = which("google-chrome")
|
|
20
|
+
if chrome_bin:
|
|
21
|
+
chrome_option.binary_location = chrome_bin
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
def get_cached_chromedriver():
|
|
25
|
+
base = Path.home() / ".wdm" / "drivers" / "chromedriver" / "linux64"
|
|
26
|
+
if not base.exists():
|
|
27
|
+
return None
|
|
28
|
+
candidates = sorted(base.glob("*/chromedriver-linux64/chromedriver"), reverse=True)
|
|
29
|
+
for candidate in candidates:
|
|
30
|
+
if candidate.exists():
|
|
31
|
+
return str(candidate)
|
|
32
|
+
return None
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
def start_with_ports(driver_path):
|
|
36
|
+
last_error = None
|
|
37
|
+
for port in (9515, 9516, 9517, 9518):
|
|
38
|
+
try:
|
|
39
|
+
return webdriver.Chrome(
|
|
40
|
+
service=Service(driver_path, port=port), options=chrome_option
|
|
41
|
+
)
|
|
42
|
+
except Exception as e:
|
|
43
|
+
last_error = e
|
|
44
|
+
if last_error is not None:
|
|
45
|
+
raise last_error
|
|
46
|
+
raise RuntimeError("ChromeDriver failed to start on all configured ports.")
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
def create_driver():
|
|
50
|
+
errors = []
|
|
51
|
+
|
|
52
|
+
local_driver = which("chromedriver")
|
|
53
|
+
if local_driver:
|
|
54
|
+
try:
|
|
55
|
+
return start_with_ports(local_driver)
|
|
56
|
+
except Exception as e:
|
|
57
|
+
errors.append(f"local chromedriver failed: {e}")
|
|
58
|
+
|
|
59
|
+
cached_driver = get_cached_chromedriver()
|
|
60
|
+
if cached_driver:
|
|
61
|
+
try:
|
|
62
|
+
return start_with_ports(cached_driver)
|
|
63
|
+
except Exception as e:
|
|
64
|
+
errors.append(f"cached chromedriver failed: {e}")
|
|
65
|
+
|
|
66
|
+
try:
|
|
67
|
+
downloaded_driver = ChromeDriverManager().install()
|
|
68
|
+
return start_with_ports(downloaded_driver)
|
|
69
|
+
except Exception as e:
|
|
70
|
+
errors.append(f"downloaded chromedriver failed: {e}")
|
|
71
|
+
|
|
72
|
+
print("ChromeDriver start failed.")
|
|
73
|
+
print("Likely reason: ChromeDriver could not bind localhost port.")
|
|
74
|
+
print("Fix steps:")
|
|
75
|
+
print("1) Run this script in your normal terminal/session (not restricted sandbox).")
|
|
76
|
+
print("2) Close old Chrome/ChromeDriver processes and run again.")
|
|
77
|
+
print("3) Ensure localhost socket binding is allowed on your system.")
|
|
78
|
+
print("4) If needed, install matching chromedriver manually.")
|
|
79
|
+
print("Details:")
|
|
80
|
+
for err in errors:
|
|
81
|
+
print(f"- {err}")
|
|
82
|
+
sys.exit(1)
|
|
83
|
+
|
|
84
|
+
|
|
85
|
+
driver = create_driver()
|
|
86
|
+
|
|
87
|
+
# If hosted URL is provided, use it directly. Otherwise fallback to local index.html.
|
|
88
|
+
WEBSITE_URL = "https://spech-to-tex.netlify.app/"
|
|
89
|
+
if WEBSITE_URL.startswith(("http://", "https://")):
|
|
90
|
+
website = WEBSITE_URL
|
|
91
|
+
else:
|
|
92
|
+
website = Path(getcwd(), "index.html").resolve().as_uri()
|
|
93
|
+
|
|
94
|
+
driver.get(website)
|
|
95
|
+
|
|
96
|
+
rec_file = Path(getcwd()) / "input.text"
|
|
97
|
+
rec_file.touch(exist_ok=True)
|
|
98
|
+
|
|
99
|
+
def listen():
|
|
100
|
+
try:
|
|
101
|
+
start_button = WebDriverWait(driver, 20).until(
|
|
102
|
+
EC.element_to_be_clickable((By.ID, "startButton"))
|
|
103
|
+
)
|
|
104
|
+
start_button.click()
|
|
105
|
+
print("Listening...")
|
|
106
|
+
output_text = ""
|
|
107
|
+
while True:
|
|
108
|
+
output_element = WebDriverWait(driver, 20).until(
|
|
109
|
+
EC.presence_of_element_located((By.ID, "output"))
|
|
110
|
+
)
|
|
111
|
+
current_text = output_element.text.strip()
|
|
112
|
+
|
|
113
|
+
if current_text and current_text != output_text:
|
|
114
|
+
output_text = current_text
|
|
115
|
+
with open(rec_file, "w") as file:
|
|
116
|
+
file.write(output_text.lower())
|
|
117
|
+
print("USER : " + output_text)
|
|
118
|
+
except KeyboardInterrupt:
|
|
119
|
+
pass
|
|
120
|
+
except Exception as e:
|
|
121
|
+
print(e)
|
|
122
|
+
|
|
123
|
+
listen()
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
Metadata-Version: 2.1
|
|
2
|
+
Name: backend00300
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: This is speech to text package created by Manas Singh Rajput
|
|
5
|
+
Home-page: UNKNOWN
|
|
6
|
+
Author: Manas Singh Rajput
|
|
7
|
+
Author-email: singmanassingh123456789@gmail.com, veerendrapratapsingh804@gmail.com
|
|
8
|
+
License: UNKNOWN
|
|
9
|
+
Platform: UNKNOWN
|
|
10
|
+
|
|
11
|
+
UNKNOWN
|
|
12
|
+
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
backend00300
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
from setuptools import setup, find_packages
|
|
2
|
+
|
|
3
|
+
setup(
|
|
4
|
+
name="backend00300",
|
|
5
|
+
version="0.1.0",
|
|
6
|
+
author="Manas Singh Rajput",
|
|
7
|
+
author_email="singmanassingh123456789@gmail.com, veerendrapratapsingh804@gmail.com",
|
|
8
|
+
description="This is speech to text package created by Manas Singh Rajput",
|
|
9
|
+
packages=find_packages(),
|
|
10
|
+
install_requires=[
|
|
11
|
+
"selenium",
|
|
12
|
+
"webdriver_manager",
|
|
13
|
+
],
|
|
14
|
+
)
|
|
15
|
+
|
|
16
|
+
|