webscout 6.3__py3-none-any.whl → 6.5__py3-none-any.whl

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.

Potentially problematic release.


This version of webscout might be problematic. Click here for more details.

Files changed (131) hide show
  1. webscout/AIauto.py +191 -176
  2. webscout/AIbase.py +0 -197
  3. webscout/AIutel.py +441 -1130
  4. webscout/DWEBS.py +189 -35
  5. webscout/{YTdownloader.py → Extra/YTToolkit/YTdownloader.py} +990 -1103
  6. webscout/Extra/YTToolkit/__init__.py +3 -0
  7. webscout/{transcriber.py → Extra/YTToolkit/transcriber.py} +479 -551
  8. webscout/Extra/YTToolkit/ytapi/__init__.py +6 -0
  9. webscout/Extra/YTToolkit/ytapi/channel.py +307 -0
  10. webscout/Extra/YTToolkit/ytapi/errors.py +13 -0
  11. webscout/Extra/YTToolkit/ytapi/extras.py +45 -0
  12. webscout/Extra/YTToolkit/ytapi/https.py +88 -0
  13. webscout/Extra/YTToolkit/ytapi/patterns.py +61 -0
  14. webscout/Extra/YTToolkit/ytapi/playlist.py +59 -0
  15. webscout/Extra/YTToolkit/ytapi/pool.py +8 -0
  16. webscout/Extra/YTToolkit/ytapi/query.py +37 -0
  17. webscout/Extra/YTToolkit/ytapi/stream.py +60 -0
  18. webscout/Extra/YTToolkit/ytapi/utils.py +62 -0
  19. webscout/Extra/YTToolkit/ytapi/video.py +102 -0
  20. webscout/Extra/__init__.py +3 -1
  21. webscout/Extra/autocoder/__init__.py +9 -0
  22. webscout/Extra/autocoder/autocoder_utiles.py +121 -0
  23. webscout/Extra/autocoder/rawdog.py +680 -0
  24. webscout/Extra/autollama.py +246 -195
  25. webscout/Extra/gguf.py +81 -56
  26. webscout/Extra/markdownlite/__init__.py +862 -0
  27. webscout/Extra/weather_ascii.py +2 -2
  28. webscout/LLM.py +206 -43
  29. webscout/Litlogger/__init__.py +681 -0
  30. webscout/Provider/DARKAI.py +1 -1
  31. webscout/Provider/EDITEE.py +1 -1
  32. webscout/Provider/NinjaChat.py +1 -1
  33. webscout/Provider/PI.py +120 -35
  34. webscout/Provider/Perplexity.py +590 -598
  35. webscout/Provider/Reka.py +0 -1
  36. webscout/Provider/RoboCoders.py +206 -0
  37. webscout/Provider/TTI/AiForce/__init__.py +22 -0
  38. webscout/Provider/TTI/AiForce/async_aiforce.py +257 -0
  39. webscout/Provider/TTI/AiForce/sync_aiforce.py +242 -0
  40. webscout/Provider/TTI/Nexra/__init__.py +22 -0
  41. webscout/Provider/TTI/Nexra/async_nexra.py +286 -0
  42. webscout/Provider/TTI/Nexra/sync_nexra.py +258 -0
  43. webscout/Provider/TTI/PollinationsAI/__init__.py +23 -0
  44. webscout/Provider/TTI/PollinationsAI/async_pollinations.py +330 -0
  45. webscout/Provider/TTI/PollinationsAI/sync_pollinations.py +285 -0
  46. webscout/Provider/TTI/__init__.py +2 -4
  47. webscout/Provider/TTI/artbit/__init__.py +22 -0
  48. webscout/Provider/TTI/artbit/async_artbit.py +184 -0
  49. webscout/Provider/TTI/artbit/sync_artbit.py +176 -0
  50. webscout/Provider/TTI/blackbox/__init__.py +4 -0
  51. webscout/Provider/TTI/blackbox/async_blackbox.py +212 -0
  52. webscout/Provider/TTI/{blackboximage.py → blackbox/sync_blackbox.py} +199 -153
  53. webscout/Provider/TTI/deepinfra/__init__.py +4 -0
  54. webscout/Provider/TTI/deepinfra/async_deepinfra.py +227 -0
  55. webscout/Provider/TTI/deepinfra/sync_deepinfra.py +199 -0
  56. webscout/Provider/TTI/huggingface/__init__.py +22 -0
  57. webscout/Provider/TTI/huggingface/async_huggingface.py +199 -0
  58. webscout/Provider/TTI/huggingface/sync_huggingface.py +195 -0
  59. webscout/Provider/TTI/imgninza/__init__.py +4 -0
  60. webscout/Provider/TTI/imgninza/async_ninza.py +214 -0
  61. webscout/Provider/TTI/{imgninza.py → imgninza/sync_ninza.py} +209 -136
  62. webscout/Provider/TTI/talkai/__init__.py +4 -0
  63. webscout/Provider/TTI/talkai/async_talkai.py +229 -0
  64. webscout/Provider/TTI/talkai/sync_talkai.py +207 -0
  65. webscout/Provider/TTS/__init__.py +5 -1
  66. webscout/Provider/TTS/deepgram.py +183 -0
  67. webscout/Provider/TTS/elevenlabs.py +137 -0
  68. webscout/Provider/TTS/gesserit.py +151 -0
  69. webscout/Provider/TTS/murfai.py +139 -0
  70. webscout/Provider/TTS/parler.py +134 -107
  71. webscout/Provider/TTS/streamElements.py +360 -275
  72. webscout/Provider/TTS/utils.py +280 -0
  73. webscout/Provider/TTS/voicepod.py +116 -116
  74. webscout/Provider/__init__.py +8 -1
  75. webscout/Provider/askmyai.py +2 -2
  76. webscout/Provider/cerebras.py +227 -219
  77. webscout/Provider/llama3mitril.py +0 -1
  78. webscout/Provider/meta.py +794 -779
  79. webscout/Provider/mhystical.py +176 -0
  80. webscout/Provider/perplexitylabs.py +265 -0
  81. webscout/Provider/twitterclone.py +251 -245
  82. webscout/Provider/typegpt.py +358 -0
  83. webscout/__init__.py +9 -8
  84. webscout/__main__.py +5 -5
  85. webscout/cli.py +252 -280
  86. webscout/conversation.py +227 -0
  87. webscout/exceptions.py +161 -29
  88. webscout/litagent/__init__.py +172 -0
  89. webscout/litprinter/__init__.py +832 -0
  90. webscout/optimizers.py +270 -0
  91. webscout/prompt_manager.py +279 -0
  92. webscout/scout/__init__.py +11 -0
  93. webscout/scout/core.py +884 -0
  94. webscout/scout/element.py +459 -0
  95. webscout/scout/parsers/__init__.py +69 -0
  96. webscout/scout/parsers/html5lib_parser.py +172 -0
  97. webscout/scout/parsers/html_parser.py +236 -0
  98. webscout/scout/parsers/lxml_parser.py +178 -0
  99. webscout/scout/utils.py +38 -0
  100. webscout/swiftcli/__init__.py +810 -0
  101. webscout/update_checker.py +125 -0
  102. webscout/version.py +1 -1
  103. webscout/zeroart/__init__.py +55 -0
  104. webscout/zeroart/base.py +61 -0
  105. webscout/zeroart/effects.py +99 -0
  106. webscout/zeroart/fonts.py +816 -0
  107. webscout/zerodir/__init__.py +225 -0
  108. {webscout-6.3.dist-info → webscout-6.5.dist-info}/METADATA +37 -112
  109. webscout-6.5.dist-info/RECORD +179 -0
  110. webscout/Agents/Onlinesearcher.py +0 -182
  111. webscout/Agents/__init__.py +0 -2
  112. webscout/Agents/functioncall.py +0 -248
  113. webscout/Bing_search.py +0 -154
  114. webscout/Provider/TTI/AIuncensoredimage.py +0 -103
  115. webscout/Provider/TTI/Nexra.py +0 -120
  116. webscout/Provider/TTI/PollinationsAI.py +0 -138
  117. webscout/Provider/TTI/WebSimAI.py +0 -142
  118. webscout/Provider/TTI/aiforce.py +0 -160
  119. webscout/Provider/TTI/artbit.py +0 -141
  120. webscout/Provider/TTI/deepinfra.py +0 -148
  121. webscout/Provider/TTI/huggingface.py +0 -155
  122. webscout/Provider/TTI/talkai.py +0 -116
  123. webscout/g4f.py +0 -666
  124. webscout/models.py +0 -23
  125. webscout/requestsHTMLfix.py +0 -775
  126. webscout/webai.py +0 -2590
  127. webscout-6.3.dist-info/RECORD +0 -124
  128. {webscout-6.3.dist-info → webscout-6.5.dist-info}/LICENSE.md +0 -0
  129. {webscout-6.3.dist-info → webscout-6.5.dist-info}/WHEEL +0 -0
  130. {webscout-6.3.dist-info → webscout-6.5.dist-info}/entry_points.txt +0 -0
  131. {webscout-6.3.dist-info → webscout-6.5.dist-info}/top_level.txt +0 -0
@@ -0,0 +1,280 @@
1
+ """
2
+ Text processing utilities for TTS providers.
3
+ """
4
+ from typing import List, Dict, Tuple, Set, Optional, Pattern
5
+ import re
6
+
7
+
8
+ class SentenceTokenizer:
9
+ """Advanced sentence tokenizer with support for complex cases and proper formatting."""
10
+
11
+ def __init__(self) -> None:
12
+ # Common abbreviations by category
13
+ self.TITLES: Set[str] = {
14
+ 'mr', 'mrs', 'ms', 'dr', 'prof', 'rev', 'sr', 'jr', 'esq',
15
+ 'hon', 'pres', 'gov', 'atty', 'supt', 'det', 'rev', 'col','maj', 'gen', 'capt', 'cmdr',
16
+ 'lt', 'sgt', 'cpl', 'pvt'
17
+ }
18
+
19
+ self.ACADEMIC: Set[str] = {
20
+ 'ph.d', 'phd', 'm.d', 'md', 'b.a', 'ba', 'm.a', 'ma', 'd.d.s', 'dds',
21
+ 'm.b.a', 'mba', 'b.sc', 'bsc', 'm.sc', 'msc', 'llb', 'll.b', 'bl'
22
+ }
23
+
24
+ self.ORGANIZATIONS: Set[str] = {
25
+ 'inc', 'ltd', 'co', 'corp', 'llc', 'llp', 'assn', 'bros', 'plc', 'cos',
26
+ 'intl', 'dept', 'est', 'dist', 'mfg', 'div'
27
+ }
28
+
29
+ self.MONTHS: Set[str] = {
30
+ 'jan', 'feb', 'mar', 'apr', 'jun', 'jul', 'aug', 'sep', 'oct', 'nov', 'dec'
31
+ }
32
+
33
+ self.UNITS: Set[str] = {
34
+ 'oz', 'pt', 'qt', 'gal', 'ml', 'cc', 'km', 'cm', 'mm', 'ft', 'in',
35
+ 'kg', 'lb', 'lbs', 'hz', 'khz', 'mhz', 'ghz', 'kb', 'mb', 'gb', 'tb'
36
+ }
37
+
38
+ self.TECHNOLOGY: Set[str] = {
39
+ 'v', 'ver', 'app', 'sys', 'dir', 'exe', 'lib', 'api', 'sdk', 'url',
40
+ 'cpu', 'gpu', 'ram', 'rom', 'hdd', 'ssd', 'lan', 'wan', 'sql', 'html'
41
+ }
42
+
43
+ self.MISC: Set[str] = {
44
+ 'vs', 'etc', 'ie', 'eg', 'no', 'al', 'ca', 'cf', 'pp', 'est', 'st',
45
+ 'approx', 'appt', 'apt', 'dept', 'depts', 'min', 'max', 'avg'
46
+ }
47
+
48
+ # Combine all abbreviations
49
+ self.all_abbreviations: Set[str] = (
50
+ self.TITLES | self.ACADEMIC | self.ORGANIZATIONS |
51
+ self.MONTHS | self.UNITS | self.TECHNOLOGY | self.MISC
52
+ )
53
+
54
+ # Special patterns
55
+ self.ELLIPSIS: str = r'\.{2,}|…'
56
+ self.URL_PATTERN: str = (
57
+ r'(?:https?:\/\/|www\.)[\w\-\.]+\.[a-zA-Z]{2,}(?:\/[^\s]*)?'
58
+ )
59
+ self.EMAIL_PATTERN: str = r'[\w\.-]+@[\w\.-]+\.\w+'
60
+ self.NUMBER_PATTERN: str = (
61
+ r'\d+(?:\.\d+)?(?:%|°|km|cm|mm|m|kg|g|lb|ft|in|mph|kmh|hz|mhz|ghz)?'
62
+ )
63
+
64
+ # Quote and bracket pairs
65
+ self.QUOTE_PAIRS: Dict[str, str] = {
66
+ '"': '"', "'": "'", '"': '"', "「": "」", "『": "』",
67
+ "«": "»", "‹": "›", "'": "'", "‚": "'"
68
+ }
69
+
70
+ self.BRACKETS: Dict[str, str] = {
71
+ '(': ')', '[': ']', '{': '}', '⟨': '⟩', '「': '」',
72
+ '『': '』', '【': '】', '〖': '〗', '「': '」'
73
+ }
74
+
75
+ # Compile regex patterns
76
+ self._compile_patterns()
77
+
78
+ def _compile_patterns(self) -> None:
79
+ """Compile regex patterns for better performance."""
80
+ # Pattern for finding potential sentence boundaries
81
+ self.SENTENCE_END: Pattern = re.compile(
82
+ r'''
83
+ # Group for sentence endings
84
+ (?:
85
+ # Standard endings with optional quotes/brackets
86
+ (?<=[.!?])[\"\'\)\]\}»›」』\s]*
87
+
88
+ # Ellipsis
89
+ |(?:\.{2,}|…)
90
+
91
+ # Asian-style endings
92
+ |(?<=[。!?」』】\s])
93
+ )
94
+
95
+ # Must be followed by whitespace and capital letter or number
96
+ (?=\s+(?:[A-Z0-9]|["'({[\[「『《‹〈][A-Z]))
97
+ ''',
98
+ re.VERBOSE
99
+ )
100
+
101
+ # Pattern for abbreviations
102
+ abbrev_pattern = '|'.join(re.escape(abbr) for abbr in self.all_abbreviations)
103
+ self.ABBREV_PATTERN: Pattern = re.compile(
104
+ fr'\b(?:{abbrev_pattern})\.?',
105
+ re.IGNORECASE
106
+ )
107
+
108
+ def _protect_special_cases(self, text: str) -> Tuple[str, Dict[str, str]]:
109
+ """Protect URLs, emails, and other special cases from being split."""
110
+ protected = text
111
+ placeholders: Dict[str, str] = {}
112
+ counter = 0
113
+
114
+ # Protect URLs and emails
115
+ for pattern in [self.URL_PATTERN, self.EMAIL_PATTERN]:
116
+ for match in re.finditer(pattern, protected):
117
+ placeholder = f'__PROTECTED_{counter}__'
118
+ placeholders[placeholder] = match.group()
119
+ protected = protected.replace(match.group(), placeholder)
120
+ counter += 1
121
+
122
+ # Protect quoted content
123
+ stack = []
124
+ protected_chars = list(protected)
125
+ i = 0
126
+ while i < len(protected_chars):
127
+ char = protected_chars[i]
128
+ if char in self.QUOTE_PAIRS:
129
+ stack.append((char, i))
130
+ elif stack and char == self.QUOTE_PAIRS[stack[-1][0]]:
131
+ start_quote, start_idx = stack.pop()
132
+ content = ''.join(protected_chars[start_idx:i + 1])
133
+ placeholder = f'__PROTECTED_{counter}__'
134
+ placeholders[placeholder] = content
135
+ protected_chars[start_idx:i + 1] = list(placeholder)
136
+ counter += 1
137
+ i += 1
138
+
139
+ return ''.join(protected_chars), placeholders
140
+
141
+ def _restore_special_cases(self, text: str, placeholders: Dict[str, str]) -> str:
142
+ """Restore protected content."""
143
+ restored = text
144
+ for placeholder, original in placeholders.items():
145
+ restored = restored.replace(placeholder, original)
146
+ return restored
147
+
148
+ def _handle_abbreviations(self, text: str) -> str:
149
+ """Handle abbreviations to prevent incorrect sentence splitting."""
150
+ def replace_abbrev(match: re.Match) -> str:
151
+ abbr = match.group().lower().rstrip('.')
152
+ if abbr in self.all_abbreviations:
153
+ return match.group().replace('.', '__DOT__')
154
+ return match.group()
155
+
156
+ return self.ABBREV_PATTERN.sub(replace_abbrev, text)
157
+
158
+ def _normalize_whitespace(self, text: str) -> str:
159
+ """Normalize whitespace while preserving paragraph breaks."""
160
+ # Replace multiple newlines with special marker
161
+ text = re.sub(r'\n\s*\n', ' __PARA__ ', text)
162
+ # Normalize remaining whitespace
163
+ text = re.sub(r'\s+', ' ', text)
164
+ return text.strip()
165
+
166
+ def _restore_formatting(self, sentences: List[str]) -> List[str]:
167
+ """Restore original formatting and clean up sentences."""
168
+ restored = []
169
+ for sentence in sentences:
170
+ # Restore dots in abbreviations
171
+ sentence = sentence.replace('__DOT__', '.')
172
+
173
+ # Restore paragraph breaks
174
+ sentence = sentence.replace('__PARA__', '\n\n')
175
+
176
+ # Clean up whitespace
177
+ sentence = re.sub(r'\s+', ' ', sentence).strip()
178
+
179
+ # Capitalize first letter if it's lowercase and not an abbreviation
180
+ words = sentence.split()
181
+ if words and words[0].lower() not in self.all_abbreviations:
182
+ sentence = sentence[0].upper() + sentence[1:]
183
+
184
+ if sentence:
185
+ restored.append(sentence)
186
+
187
+ return restored
188
+
189
+ def tokenize(self, text: str) -> List[str]:
190
+ """
191
+ Split text into sentences while handling complex cases.
192
+
193
+ Args:
194
+ text (str): Input text to split into sentences.
195
+
196
+ Returns:
197
+ List[str]: List of properly formatted sentences.
198
+ """
199
+ if not text or not text.strip():
200
+ return []
201
+
202
+ # Step 1: Protect special cases
203
+ protected_text, placeholders = self._protect_special_cases(text)
204
+
205
+ # Step 2: Normalize whitespace
206
+ protected_text = self._normalize_whitespace(protected_text)
207
+
208
+ # Step 3: Handle abbreviations
209
+ protected_text = self._handle_abbreviations(protected_text)
210
+
211
+ # Step 4: Split into potential sentences
212
+ potential_sentences = self.SENTENCE_END.split(protected_text)
213
+
214
+ # Step 5: Process and restore formatting
215
+ sentences = self._restore_formatting(potential_sentences)
216
+
217
+ # Step 6: Restore special cases
218
+ sentences = [self._restore_special_cases(s, placeholders) for s in sentences]
219
+
220
+ # Step 7: Post-process sentences
221
+ final_sentences = []
222
+ current_sentence = []
223
+
224
+ for sentence in sentences:
225
+ # Skip empty sentences
226
+ if not sentence.strip():
227
+ continue
228
+
229
+ # Check if sentence might be continuation of previous
230
+ if current_sentence and sentence[0].islower():
231
+ current_sentence.append(sentence)
232
+ else:
233
+ if current_sentence:
234
+ final_sentences.append(' '.join(current_sentence))
235
+ current_sentence = [sentence]
236
+
237
+ # Add last sentence if exists
238
+ if current_sentence:
239
+ final_sentences.append(' '.join(current_sentence))
240
+
241
+ return final_sentences
242
+
243
+
244
+ def split_sentences(text: str) -> List[str]:
245
+ """
246
+ Convenience function to split text into sentences using SentenceTokenizer.
247
+
248
+ Args:
249
+ text (str): Input text to split into sentences.
250
+
251
+ Returns:
252
+ List[str]: List of properly formatted sentences.
253
+ """
254
+ tokenizer = SentenceTokenizer()
255
+ return tokenizer.tokenize(text)
256
+
257
+
258
+ if __name__ == "__main__":
259
+ # Test text with various challenging cases
260
+ test_text: str = """
261
+ Dr. Smith (Ph.D., M.D.) visited Washington D.C. on Jan. 20, 2024! He met with Prof. Johnson at 3:30 p.m.
262
+ They discussed A.I. and machine learning... "What about the U.S. market?" asked Dr. Smith.
263
+ The meeting ended at 5 p.m. Later, they went to Mr. Wilson's house (located at 123 Main St.) for dinner.
264
+
265
+ Visit our website at https://www.example.com or email us at test@example.com!
266
+ The temperature was 72.5°F (22.5°C). The company's Q3 2023 revenue was $12.5M USD.
267
+
268
+ 「これは日本語の文章です。」This is a mixed-language text! How cool is that?
269
+
270
+ Some technical specs: CPU: 3.5GHz, RAM: 16GB, Storage: 2TB SSD.
271
+ Common abbreviations: etc., i.e., e.g., vs., cf., approx. 100 units.
272
+ """
273
+
274
+ # Process and print each sentence
275
+ sentences: List[str] = split_sentences(test_text)
276
+ print("Detected sentences:")
277
+ print("-" * 80)
278
+ for i, sentence in enumerate(sentences, 1):
279
+ print(f"{i}. {sentence}")
280
+ print("-" * 80)
@@ -1,117 +1,117 @@
1
- import requests
2
- import json
3
- import time
4
- from pathlib import Path
5
- from typing import Generator
6
- from playsound import playsound
7
- from webscout import exceptions
8
- from webscout.AIbase import TTSProvider
9
-
10
- class Voicepods(TTSProvider):
11
- """
12
- A class to interact with the Voicepods text-to-speech API.
13
- """
14
-
15
- def __init__(self, timeout: int = 20, proxies: dict = None):
16
- """
17
- Initializes the Voicepods API client.
18
- """
19
- self.api_endpoint = "https://voicepods-stream.vercel.app/api/resemble"
20
- self.headers = {
21
- 'Accept': '*/*',
22
- 'Accept-Encoding': 'gzip, deflate, br, zstd',
23
- 'Accept-Language': 'en-US,en;q=0.9,en-IN;q=0.8',
24
- 'Content-Type': 'application/json',
25
- 'DNT': '1',
26
- 'Origin': 'https://voicepods-stream.vercel.app',
27
- 'Referer': 'https://voicepods-stream.vercel.app/',
28
- 'Sec-CH-UA': '"Chromium";v="128", "Not;A=Brand";v="24", "Microsoft Edge";v="128"',
29
- 'Sec-CH-UA-Mobile': '?0',
30
- 'Sec-CH-UA-Platform': '"Windows"',
31
- 'Sec-Fetch-Dest': 'empty',
32
- 'Sec-Fetch-Mode': 'cors',
33
- 'Sec-Fetch-Site': 'same-origin',
34
- 'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/128.0.0.0 Safari/537.36 Edg/128.0.0.0',
35
- }
36
- self.session = requests.Session()
37
- self.session.headers.update(self.headers)
38
- if proxies:
39
- self.session.proxies.update(proxies)
40
- self.timeout = timeout
41
- self.audio_cache_dir = Path("./audio_cache")
42
-
43
- def tts(self, text: str) -> str:
44
- """
45
- Converts text to speech using the Voicepods API.
46
-
47
- Args:
48
- text (str): The text to be converted to speech.
49
-
50
- Returns:
51
- str: The filename of the saved audio file.
52
-
53
- Raises:
54
- exceptions.FailedToGenerateResponseError: If there is an error generating or saving the audio.
55
- """
56
- payload = json.dumps({"query": text})
57
- filename = self.audio_cache_dir / f"{int(time.time())}.wav" # Using timestamp for filename
58
-
59
- try:
60
- response = self.session.post(self.api_endpoint, data=payload, timeout=self.timeout)
61
- response.raise_for_status()
62
-
63
- content_type = response.headers.get('Content-Type', '')
64
- if 'audio' not in content_type.lower():
65
- raise ValueError(f"Unexpected content type: {content_type}")
66
-
67
- audio_data = response.content
68
- self._save_audio(audio_data, filename)
69
- return filename.as_posix() # Return the filename as a string
70
-
71
- except requests.exceptions.RequestException as e:
72
- raise exceptions.FailedToGenerateResponseError(f"Error generating audio: {e}")
73
-
74
- def _save_audio(self, audio_data: bytes, filename: Path):
75
- """Saves the audio data to a WAV file in the audio cache directory."""
76
- try:
77
- # Create the audio_cache directory if it doesn't exist
78
- self.audio_cache_dir.mkdir(parents=True, exist_ok=True)
79
-
80
- riff_start = audio_data.find(b'RIFF')
81
- if riff_start == -1:
82
- raise ValueError("RIFF header not found in audio data")
83
-
84
- trimmed_audio_data = audio_data[riff_start:]
85
-
86
- with open(filename, "wb") as f:
87
- f.write(trimmed_audio_data)
88
-
89
- except Exception as e:
90
- raise exceptions.FailedToGenerateResponseError(f"Error saving audio: {e}")
91
-
92
- def play_audio(self, filename: str):
93
- """
94
- Plays an audio file using playsound.
95
-
96
- Args:
97
- filename (str): The path to the audio file.
98
-
99
- Raises:
100
- RuntimeError: If there is an error playing the audio.
101
- """
102
- try:
103
- playsound(filename)
104
- except Exception as e:
105
- raise RuntimeError(f"Error playing audio: {e}")
106
-
107
- # Example usage
108
- if __name__ == "__main__":
109
-
110
- voicepods = Voicepods()
111
- text = "Hello, this is a test of the Voicepods text-to-speech system."
112
-
113
- print("Generating audio...")
114
- audio_file = voicepods.tts(text)
115
-
116
- print("Playing audio...")
1
+ import requests
2
+ import json
3
+ import time
4
+ from pathlib import Path
5
+ from typing import Generator
6
+ from playsound import playsound
7
+ from webscout import exceptions
8
+ from webscout.AIbase import TTSProvider
9
+
10
+ class Voicepods(TTSProvider):
11
+ """
12
+ A class to interact with the Voicepods text-to-speech API.
13
+ """
14
+
15
+ def __init__(self, timeout: int = 20, proxies: dict = None):
16
+ """
17
+ Initializes the Voicepods API client.
18
+ """
19
+ self.api_endpoint = "https://voicepods-stream.vercel.app/api/resemble"
20
+ self.headers = {
21
+ 'Accept': '*/*',
22
+ 'Accept-Encoding': 'gzip, deflate, br, zstd',
23
+ 'Accept-Language': 'en-US,en;q=0.9,en-IN;q=0.8',
24
+ 'Content-Type': 'application/json',
25
+ 'DNT': '1',
26
+ 'Origin': 'https://voicepods-stream.vercel.app',
27
+ 'Referer': 'https://voicepods-stream.vercel.app/',
28
+ 'Sec-CH-UA': '"Chromium";v="128", "Not;A=Brand";v="24", "Microsoft Edge";v="128"',
29
+ 'Sec-CH-UA-Mobile': '?0',
30
+ 'Sec-CH-UA-Platform': '"Windows"',
31
+ 'Sec-Fetch-Dest': 'empty',
32
+ 'Sec-Fetch-Mode': 'cors',
33
+ 'Sec-Fetch-Site': 'same-origin',
34
+ 'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/128.0.0.0 Safari/537.36 Edg/128.0.0.0',
35
+ }
36
+ self.session = requests.Session()
37
+ self.session.headers.update(self.headers)
38
+ if proxies:
39
+ self.session.proxies.update(proxies)
40
+ self.timeout = timeout
41
+ self.audio_cache_dir = Path("./audio_cache")
42
+
43
+ def tts(self, text: str) -> str:
44
+ """
45
+ Converts text to speech using the Voicepods API.
46
+
47
+ Args:
48
+ text (str): The text to be converted to speech.
49
+
50
+ Returns:
51
+ str: The filename of the saved audio file.
52
+
53
+ Raises:
54
+ exceptions.FailedToGenerateResponseError: If there is an error generating or saving the audio.
55
+ """
56
+ payload = json.dumps({"query": text})
57
+ filename = self.audio_cache_dir / f"{int(time.time())}.wav" # Using timestamp for filename
58
+
59
+ try:
60
+ response = self.session.post(self.api_endpoint, data=payload, timeout=self.timeout)
61
+ response.raise_for_status()
62
+
63
+ content_type = response.headers.get('Content-Type', '')
64
+ if 'audio' not in content_type.lower():
65
+ raise ValueError(f"Unexpected content type: {content_type}")
66
+
67
+ audio_data = response.content
68
+ self._save_audio(audio_data, filename)
69
+ return filename.as_posix() # Return the filename as a string
70
+
71
+ except requests.exceptions.RequestException as e:
72
+ raise exceptions.FailedToGenerateResponseError(f"Error generating audio: {e}")
73
+
74
+ def _save_audio(self, audio_data: bytes, filename: Path):
75
+ """Saves the audio data to a WAV file in the audio cache directory."""
76
+ try:
77
+ # Create the audio_cache directory if it doesn't exist
78
+ self.audio_cache_dir.mkdir(parents=True, exist_ok=True)
79
+
80
+ riff_start = audio_data.find(b'RIFF')
81
+ if riff_start == -1:
82
+ raise ValueError("RIFF header not found in audio data")
83
+
84
+ trimmed_audio_data = audio_data[riff_start:]
85
+
86
+ with open(filename, "wb") as f:
87
+ f.write(trimmed_audio_data)
88
+
89
+ except Exception as e:
90
+ raise exceptions.FailedToGenerateResponseError(f"Error saving audio: {e}")
91
+
92
+ def play_audio(self, filename: str):
93
+ """
94
+ Plays an audio file using playsound.
95
+
96
+ Args:
97
+ filename (str): The path to the audio file.
98
+
99
+ Raises:
100
+ RuntimeError: If there is an error playing the audio.
101
+ """
102
+ try:
103
+ playsound(filename)
104
+ except Exception as e:
105
+ raise RuntimeError(f"Error playing audio: {e}")
106
+
107
+ # Example usage
108
+ if __name__ == "__main__":
109
+
110
+ voicepods = Voicepods()
111
+ text = "Hello, this is a test of the Voicepods text-to-speech system."
112
+
113
+ print("Generating audio...")
114
+ audio_file = voicepods.tts(text)
115
+
116
+ print("Playing audio...")
117
117
  voicepods.play_audio(audio_file)
@@ -9,7 +9,9 @@ from .Openai import OPENAI
9
9
  from .Openai import AsyncOPENAI
10
10
  from .Koboldai import KOBOLDAI
11
11
  from .Koboldai import AsyncKOBOLDAI
12
+ from .RoboCoders import RoboCoders
12
13
  from .Perplexity import *
14
+ from .perplexitylabs import PerplexityLabs
13
15
  from .Blackboxai import BLACKBOXAI
14
16
  from .Phind import PhindSearch
15
17
  from .Phind import Phindv2
@@ -67,6 +69,8 @@ from .talkai import *
67
69
  from .askmyai import *
68
70
  from .llama3mitril import *
69
71
  from .Marcus import *
72
+ from .typegpt import *
73
+ from .mhystical import *
70
74
  __all__ = [
71
75
  'Farfalle',
72
76
  'LLAMA',
@@ -79,6 +83,7 @@ __all__ = [
79
83
  'KOBOLDAI',
80
84
  'AsyncKOBOLDAI',
81
85
  'Perplexity',
86
+ 'PerplexityLabs',
82
87
  'BLACKBOXAI',
83
88
  'PhindSearch',
84
89
  'Felo',
@@ -136,5 +141,7 @@ __all__ = [
136
141
  'Talkai',
137
142
  'Llama3Mitril',
138
143
  'Marcus',
139
-
144
+ 'RoboCoders',
145
+ 'TypeGPT',
146
+ 'Mhystical',
140
147
  ]
@@ -8,7 +8,7 @@ from webscout.AIutel import Conversation
8
8
  from webscout.AIutel import AwesomePrompts
9
9
  from webscout.AIbase import Provider
10
10
  from webscout import exceptions
11
-
11
+ from fake_useragent import UserAgent
12
12
 
13
13
  class AskMyAI(Provider):
14
14
  """
@@ -41,7 +41,7 @@ class AskMyAI(Provider):
41
41
  "Accept": "*/*",
42
42
  "Accept-Encoding": "gzip, deflate, br",
43
43
  "Accept-Language": "en-US,en;q=0.9",
44
- "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/127.0.0.0 Safari/537.36"
44
+ 'user-agent': UserAgent().random
45
45
  }
46
46
  self.__available_optimizers = (
47
47
  method