webscout 7.4__py3-none-any.whl → 7.6__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 (137) hide show
  1. webscout/AIauto.py +5 -53
  2. webscout/AIutel.py +8 -318
  3. webscout/DWEBS.py +460 -489
  4. webscout/Extra/YTToolkit/YTdownloader.py +14 -53
  5. webscout/Extra/YTToolkit/transcriber.py +12 -13
  6. webscout/Extra/YTToolkit/ytapi/video.py +0 -1
  7. webscout/Extra/__init__.py +0 -1
  8. webscout/Extra/autocoder/autocoder_utiles.py +0 -4
  9. webscout/Extra/autocoder/rawdog.py +13 -41
  10. webscout/Extra/gguf.py +652 -428
  11. webscout/Extra/weather.py +178 -156
  12. webscout/Extra/weather_ascii.py +70 -17
  13. webscout/Litlogger/core/logger.py +1 -2
  14. webscout/Litlogger/handlers/file.py +1 -1
  15. webscout/Litlogger/styles/formats.py +0 -2
  16. webscout/Litlogger/utils/detectors.py +0 -1
  17. webscout/Provider/AISEARCH/DeepFind.py +0 -1
  18. webscout/Provider/AISEARCH/ISou.py +1 -1
  19. webscout/Provider/AISEARCH/felo_search.py +0 -1
  20. webscout/Provider/AllenAI.py +24 -9
  21. webscout/Provider/C4ai.py +432 -0
  22. webscout/Provider/ChatGPTGratis.py +24 -56
  23. webscout/Provider/Cloudflare.py +18 -21
  24. webscout/Provider/DeepSeek.py +27 -48
  25. webscout/Provider/Deepinfra.py +129 -53
  26. webscout/Provider/Gemini.py +1 -1
  27. webscout/Provider/GithubChat.py +362 -0
  28. webscout/Provider/Glider.py +25 -8
  29. webscout/Provider/HF_space/qwen_qwen2.py +2 -2
  30. webscout/Provider/HeckAI.py +38 -5
  31. webscout/Provider/HuggingFaceChat.py +462 -0
  32. webscout/Provider/Jadve.py +20 -5
  33. webscout/Provider/Marcus.py +7 -50
  34. webscout/Provider/Netwrck.py +43 -67
  35. webscout/Provider/PI.py +4 -2
  36. webscout/Provider/Perplexitylabs.py +26 -6
  37. webscout/Provider/Phind.py +29 -3
  38. webscout/Provider/PizzaGPT.py +10 -51
  39. webscout/Provider/TTI/AiForce/async_aiforce.py +4 -37
  40. webscout/Provider/TTI/AiForce/sync_aiforce.py +41 -38
  41. webscout/Provider/TTI/FreeAIPlayground/__init__.py +9 -9
  42. webscout/Provider/TTI/FreeAIPlayground/async_freeaiplayground.py +206 -206
  43. webscout/Provider/TTI/FreeAIPlayground/sync_freeaiplayground.py +192 -192
  44. webscout/Provider/TTI/MagicStudio/__init__.py +2 -0
  45. webscout/Provider/TTI/MagicStudio/async_magicstudio.py +111 -0
  46. webscout/Provider/TTI/MagicStudio/sync_magicstudio.py +109 -0
  47. webscout/Provider/TTI/PollinationsAI/async_pollinations.py +5 -24
  48. webscout/Provider/TTI/PollinationsAI/sync_pollinations.py +2 -22
  49. webscout/Provider/TTI/__init__.py +2 -3
  50. webscout/Provider/TTI/aiarta/__init__.py +2 -0
  51. webscout/Provider/TTI/aiarta/async_aiarta.py +482 -0
  52. webscout/Provider/TTI/aiarta/sync_aiarta.py +440 -0
  53. webscout/Provider/TTI/fastflux/__init__.py +22 -0
  54. webscout/Provider/TTI/fastflux/async_fastflux.py +257 -0
  55. webscout/Provider/TTI/fastflux/sync_fastflux.py +247 -0
  56. webscout/Provider/TTS/__init__.py +2 -2
  57. webscout/Provider/TTS/deepgram.py +12 -39
  58. webscout/Provider/TTS/elevenlabs.py +14 -40
  59. webscout/Provider/TTS/gesserit.py +11 -35
  60. webscout/Provider/TTS/murfai.py +13 -39
  61. webscout/Provider/TTS/parler.py +17 -40
  62. webscout/Provider/TTS/speechma.py +180 -0
  63. webscout/Provider/TTS/streamElements.py +17 -44
  64. webscout/Provider/TextPollinationsAI.py +39 -59
  65. webscout/Provider/Venice.py +217 -200
  66. webscout/Provider/WiseCat.py +27 -5
  67. webscout/Provider/Youchat.py +63 -36
  68. webscout/Provider/__init__.py +13 -8
  69. webscout/Provider/akashgpt.py +28 -10
  70. webscout/Provider/copilot.py +416 -0
  71. webscout/Provider/flowith.py +196 -0
  72. webscout/Provider/freeaichat.py +32 -45
  73. webscout/Provider/granite.py +17 -53
  74. webscout/Provider/koala.py +20 -5
  75. webscout/Provider/llamatutor.py +7 -47
  76. webscout/Provider/llmchat.py +36 -53
  77. webscout/Provider/multichat.py +92 -98
  78. webscout/Provider/talkai.py +1 -0
  79. webscout/Provider/turboseek.py +3 -0
  80. webscout/Provider/tutorai.py +2 -0
  81. webscout/Provider/typegpt.py +154 -64
  82. webscout/Provider/x0gpt.py +3 -1
  83. webscout/Provider/yep.py +102 -20
  84. webscout/__init__.py +3 -0
  85. webscout/cli.py +4 -40
  86. webscout/conversation.py +1 -10
  87. webscout/exceptions.py +19 -9
  88. webscout/litagent/__init__.py +2 -2
  89. webscout/litagent/agent.py +351 -20
  90. webscout/litagent/constants.py +34 -5
  91. webscout/litprinter/__init__.py +0 -3
  92. webscout/models.py +181 -0
  93. webscout/optimizers.py +1 -1
  94. webscout/prompt_manager.py +2 -8
  95. webscout/scout/core/scout.py +1 -4
  96. webscout/scout/core/search_result.py +1 -1
  97. webscout/scout/core/text_utils.py +1 -1
  98. webscout/scout/core.py +2 -5
  99. webscout/scout/element.py +1 -1
  100. webscout/scout/parsers/html_parser.py +1 -1
  101. webscout/scout/utils.py +0 -1
  102. webscout/swiftcli/__init__.py +1 -3
  103. webscout/tempid.py +1 -1
  104. webscout/update_checker.py +55 -95
  105. webscout/version.py +1 -1
  106. webscout/webscout_search_async.py +1 -2
  107. webscout/yep_search.py +297 -297
  108. webscout-7.6.dist-info/LICENSE.md +146 -0
  109. {webscout-7.4.dist-info → webscout-7.6.dist-info}/METADATA +104 -514
  110. {webscout-7.4.dist-info → webscout-7.6.dist-info}/RECORD +113 -120
  111. webscout/Extra/autollama.py +0 -231
  112. webscout/Local/__init__.py +0 -10
  113. webscout/Local/_version.py +0 -3
  114. webscout/Local/formats.py +0 -747
  115. webscout/Local/model.py +0 -1368
  116. webscout/Local/samplers.py +0 -125
  117. webscout/Local/thread.py +0 -539
  118. webscout/Local/ui.py +0 -401
  119. webscout/Local/utils.py +0 -388
  120. webscout/Provider/Amigo.py +0 -274
  121. webscout/Provider/Bing.py +0 -243
  122. webscout/Provider/DiscordRocks.py +0 -253
  123. webscout/Provider/TTI/blackbox/__init__.py +0 -4
  124. webscout/Provider/TTI/blackbox/async_blackbox.py +0 -212
  125. webscout/Provider/TTI/blackbox/sync_blackbox.py +0 -199
  126. webscout/Provider/TTI/deepinfra/__init__.py +0 -4
  127. webscout/Provider/TTI/deepinfra/async_deepinfra.py +0 -227
  128. webscout/Provider/TTI/deepinfra/sync_deepinfra.py +0 -199
  129. webscout/Provider/TTI/imgninza/__init__.py +0 -4
  130. webscout/Provider/TTI/imgninza/async_ninza.py +0 -214
  131. webscout/Provider/TTI/imgninza/sync_ninza.py +0 -209
  132. webscout/Provider/TTS/voicepod.py +0 -117
  133. webscout/Provider/dgaf.py +0 -214
  134. webscout-7.4.dist-info/LICENSE.md +0 -211
  135. {webscout-7.4.dist-info → webscout-7.6.dist-info}/WHEEL +0 -0
  136. {webscout-7.4.dist-info → webscout-7.6.dist-info}/entry_points.txt +0 -0
  137. {webscout-7.4.dist-info → webscout-7.6.dist-info}/top_level.txt +0 -0
@@ -0,0 +1,257 @@
1
+ """AsyncFastFluxImager - Generate stunning AI art with FastFlux (async version)! ⚡
2
+
3
+ Examples:
4
+ >>> from webscout import AsyncFastFluxImager
5
+ >>> import asyncio
6
+ >>>
7
+ >>> async def main():
8
+ ... provider = AsyncFastFluxImager()
9
+ ... # Generate a single image
10
+ ... images = await provider.generate("A cool cyberpunk city at night")
11
+ ... paths = await provider.save(images, dir="my_images")
12
+ ... print(f"Saved images to: {paths}")
13
+ ...
14
+ >>> asyncio.run(main())
15
+ """
16
+
17
+ import aiohttp
18
+ import asyncio
19
+ import base64
20
+ import os
21
+ import time
22
+ from typing import List, Optional, Union, AsyncGenerator
23
+ from pathlib import Path
24
+ import aiofiles
25
+
26
+ from webscout.AIbase import AsyncImageProvider
27
+ from webscout.litagent import LitAgent
28
+
29
+
30
+ class AsyncFastFluxImager(AsyncImageProvider):
31
+ """Your go-to async provider for generating fire images with FastFlux! ⚡
32
+
33
+ Examples:
34
+ >>> provider = AsyncFastFluxImager()
35
+ >>>
36
+ >>> # Generate one image with default model
37
+ >>> async def single_image():
38
+ ... image = await provider.generate("A futuristic city")
39
+ ... await provider.save(image, "city.png")
40
+ >>>
41
+ >>> # Generate multiple with specific model
42
+ >>> async def multiple_images():
43
+ ... images = await provider.generate(
44
+ ... prompt="Space station",
45
+ ... amount=3,
46
+ ... model="flux_1_dev",
47
+ ... size="16_9"
48
+ ... )
49
+ ... await provider.save(images, dir="space_pics")
50
+ """
51
+
52
+ AVAILABLE_MODELS = [
53
+ "flux_1_schnell", # Fast generation model (default)
54
+ "flux_1_dev", # Developer model
55
+ "sana_1_6b" # SANA 1.6B model
56
+ ]
57
+
58
+
59
+
60
+ def __init__(self, timeout: int = 60, proxies: dict = None):
61
+ """Initialize your async FastFluxImager provider with custom settings ⚙️
62
+
63
+ Examples:
64
+ >>> provider = AsyncFastFluxImager(timeout=120)
65
+ >>> provider = AsyncFastFluxImager(proxies={"http": "http://proxy:8080"})
66
+
67
+ Args:
68
+ timeout (int): HTTP request timeout in seconds (default: 60)
69
+ proxies (dict, optional): Proxy configuration for requests
70
+ logging (bool): Enable/disable logging (default: True)
71
+ """
72
+ self.api_endpoint = "https://api.fastflux.co/v1/images/generate"
73
+ self.headers = {
74
+ "accept": "application/json, text/plain, */*",
75
+ "content-type": "application/json",
76
+ "origin": "https://fastflux.co",
77
+ "referer": "https://fastflux.co/",
78
+ "user-agent": LitAgent().random()
79
+ }
80
+ self.timeout = timeout
81
+ self.proxies = proxies
82
+ self.prompt: str = "AI-generated image - webscout"
83
+ self.image_extension: str = "png"
84
+
85
+
86
+ async def generate(
87
+ self,
88
+ prompt: str,
89
+ amount: int = 1,
90
+ model: str = "flux_1_schnell",
91
+ size: str = "1_1",
92
+ is_public: bool = False,
93
+ max_retries: int = 3,
94
+ retry_delay: int = 5
95
+ ) -> List[bytes]:
96
+ """Generate some fire images from your prompt asynchronously! ⚡
97
+
98
+ Examples:
99
+ >>> provider = AsyncFastFluxImager()
100
+ >>> async def example():
101
+ ... # Basic usage
102
+ ... images = await provider.generate("Cool art")
103
+ ... # Advanced usage
104
+ ... images = await provider.generate(
105
+ ... prompt="Epic dragon",
106
+ ... amount=2,
107
+ ... model="flux_1_dev",
108
+ ... size="16_9"
109
+ ... )
110
+
111
+ Args:
112
+ prompt (str): Your image description
113
+ amount (int): How many images you want (default: 1)
114
+ model (str): Model to use - check AVAILABLE_MODELS (default: "flux_1_schnell")
115
+ size (str): Image size ratio (default: "1_1")
116
+ is_public (bool): Whether to make the image public (default: False)
117
+ max_retries (int): Max retry attempts if something fails (default: 3)
118
+ retry_delay (int): Seconds to wait between retries (default: 5)
119
+
120
+ Returns:
121
+ List[bytes]: Your generated images
122
+
123
+ Raises:
124
+ ValueError: If the inputs ain't valid
125
+ aiohttp.ClientError: If the API calls fail after retries
126
+ """
127
+ if not prompt:
128
+ raise ValueError("Yo fam, the prompt can't be empty! 🤔")
129
+ if not isinstance(amount, int) or amount < 1:
130
+ raise ValueError("Amount needs to be a positive number! 📈")
131
+ if model not in self.AVAILABLE_MODELS:
132
+ raise ValueError(f"Model must be one of {self.AVAILABLE_MODELS}! 🎯")
133
+ if size not in self.AVAILABLE_SIZES:
134
+ raise ValueError(f"Size must be one of {self.AVAILABLE_SIZES}! 📏")
135
+
136
+ self.prompt = prompt
137
+ response = []
138
+
139
+ # Prepare payload
140
+ payload = {
141
+ "prompt": prompt,
142
+ "model": model,
143
+ "size": size,
144
+ "isPublic": is_public
145
+ }
146
+
147
+
148
+ async with aiohttp.ClientSession(headers=self.headers) as session:
149
+ for i in range(amount):
150
+ for attempt in range(max_retries):
151
+ try:
152
+ async with session.post(
153
+ self.api_endpoint,
154
+ json=payload,
155
+ timeout=self.timeout,
156
+ proxy=self.proxies.get('http') if self.proxies else None
157
+ ) as resp:
158
+ resp.raise_for_status()
159
+ result = await resp.json()
160
+
161
+ if result and 'result' in result:
162
+ # Get base64 data and remove header
163
+ image_data = result['result']
164
+ base64_data = image_data.split(',')[1]
165
+
166
+ # Decode base64 data
167
+ image_bytes = base64.b64decode(base64_data)
168
+ response.append(image_bytes)
169
+ break
170
+ else:
171
+ raise aiohttp.ClientError("Invalid response format")
172
+
173
+ except aiohttp.ClientError as e:
174
+ if attempt == max_retries - 1:
175
+ raise aiohttp.ClientError(f"Failed to generate image after {max_retries} attempts: {e}")
176
+ await asyncio.sleep(retry_delay)
177
+
178
+ return response
179
+
180
+ async def save(
181
+ self,
182
+ response: Union[AsyncGenerator[bytes, None], List[bytes]],
183
+ name: Optional[str] = None,
184
+ dir: Optional[Union[str, Path]] = None,
185
+ filenames_prefix: str = "",
186
+ ) -> List[str]:
187
+ """Save your fire generated images asynchronously! 💾
188
+
189
+ Examples:
190
+ >>> provider = AsyncFastFluxImager()
191
+ >>> async def example():
192
+ ... images = await provider.generate("Cool art")
193
+ ... # Save with default settings
194
+ ... paths = await provider.save(images)
195
+ ... # Save with custom name and directory
196
+ ... paths = await provider.save(
197
+ ... images,
198
+ ... name="my_art",
199
+ ... dir="my_images",
200
+ ... filenames_prefix="test_"
201
+ ... )
202
+
203
+ Args:
204
+ response (Union[AsyncGenerator[bytes, None], List[bytes]]): Your generated images
205
+ name (Optional[str]): Custom name for your images
206
+ dir (Optional[Union[str, Path]]): Where to save the images (default: current directory)
207
+ filenames_prefix (str): Prefix for your image files
208
+
209
+ Returns:
210
+ List[str]: Paths to your saved images
211
+ """
212
+ save_dir = dir if dir else os.getcwd()
213
+ if not os.path.exists(save_dir):
214
+ os.makedirs(save_dir)
215
+
216
+
217
+ name = self.prompt if name is None else name
218
+
219
+ # Clean up name for filename use
220
+ safe_name = "".join(c if c.isalnum() or c in "_-" else "_" for c in name)
221
+ safe_name = safe_name[:50] # Truncate if too long
222
+
223
+ # Handle both List[bytes] and AsyncGenerator
224
+ if isinstance(response, list):
225
+ image_list = response
226
+ else:
227
+ image_list = [chunk async for chunk in response]
228
+
229
+
230
+ async def save_single_image(image_bytes: bytes, index: int) -> str:
231
+ filename = f"{filenames_prefix}{safe_name}_{index}.{self.image_extension}"
232
+ filepath = os.path.join(save_dir, filename)
233
+
234
+ async with aiofiles.open(filepath, "wb") as f:
235
+ await f.write(image_bytes)
236
+
237
+ return filename
238
+
239
+ tasks = [save_single_image(img, i) for i, img in enumerate(image_list)]
240
+ saved_paths = await asyncio.gather(*tasks)
241
+
242
+
243
+ return saved_paths
244
+
245
+
246
+ if __name__ == "__main__":
247
+ # Example usage
248
+ async def main():
249
+ provider = AsyncFastFluxImager()
250
+ try:
251
+ images = await provider.generate("A cyberpunk city at night with neon lights", amount=1)
252
+ paths = await provider.save(images, dir="generated_images")
253
+ print(f"Successfully saved images to: {paths}")
254
+ except Exception as e:
255
+ print(f"Oops, something went wrong: {e}")
256
+
257
+ asyncio.run(main())
@@ -0,0 +1,247 @@
1
+ """FastFluxImager Synchronous Provider - Generate stunning AI art with FastFlux! 🎨
2
+
3
+ Examples:
4
+ >>> from webscout import FastFluxImager
5
+ >>> provider = FastFluxImager()
6
+ >>>
7
+ >>> # Generate a single image
8
+ >>> images = provider.generate("A cool cyberpunk city at night")
9
+ >>> paths = provider.save(images, dir="my_images")
10
+ >>>
11
+ >>> # Generate multiple images with different settings
12
+ >>> images = provider.generate(
13
+ ... prompt="Epic dragon breathing fire",
14
+ ... amount=2,
15
+ ... model="flux_1_schnell"
16
+ ... )
17
+ >>> provider.save(images, dir="dragon_pics")
18
+ """
19
+
20
+ import requests
21
+ import base64
22
+ import json
23
+ import os
24
+ import time
25
+ from typing import List, Optional, Union
26
+ from requests.exceptions import RequestException
27
+ from pathlib import Path
28
+
29
+ from webscout.AIbase import ImageProvider
30
+ from webscout.litagent import LitAgent
31
+
32
+ # Get a fresh user agent! 🔄
33
+ agent = LitAgent()
34
+
35
+ class FastFluxImager(ImageProvider):
36
+ """Your go-to provider for generating fire images with FastFlux! 🎨
37
+
38
+ Examples:
39
+ >>> provider = FastFluxImager()
40
+ >>> # Generate one image with default model
41
+ >>> image = provider.generate("A futuristic city")
42
+ >>> provider.save(image, "city.png")
43
+ >>>
44
+ >>> # Generate multiple images with specific model
45
+ >>> images = provider.generate(
46
+ ... prompt="Space station",
47
+ ... amount=3,
48
+ ... model="flux_1_dev"
49
+ ... )
50
+ >>> provider.save(images, dir="space_pics")
51
+ """
52
+
53
+ AVAILABLE_MODELS = [
54
+ "flux_1_schnell", # Fast generation model (default)
55
+ "flux_1_dev", # Developer model
56
+ "sana_1_6b" # SANA 1.6B model
57
+ ]
58
+
59
+
60
+ def __init__(self, timeout: int = 60, proxies: dict = None):
61
+ """Initialize your FastFluxImager provider with custom settings
62
+
63
+ Examples:
64
+ >>> provider = FastFluxImager(timeout=120)
65
+ >>> provider = FastFluxImager(proxies={"http": "http://proxy:8080"})
66
+
67
+ Args:
68
+ timeout (int): HTTP request timeout in seconds (default: 60)
69
+ proxies (dict, optional): Proxy configuration for requests
70
+ logging (bool): Enable/disable logging (default: True)
71
+ """
72
+ self.api_endpoint = "https://api.fastflux.co/v1/images/generate"
73
+ self.headers = {
74
+ "accept": "application/json, text/plain, */*",
75
+ "content-type": "application/json",
76
+ "origin": "https://fastflux.co",
77
+ "referer": "https://fastflux.co/",
78
+ "user-agent": agent.random()
79
+ }
80
+ self.session = requests.Session()
81
+ self.session.headers.update(self.headers)
82
+ if proxies:
83
+ self.session.proxies.update(proxies)
84
+ self.timeout = timeout
85
+ self.prompt: str = "AI-generated image - webscout"
86
+ self.image_extension: str = "png"
87
+
88
+
89
+ def generate(
90
+ self,
91
+ prompt: str,
92
+ amount: int = 1,
93
+ model: str = "flux_1_schnell",
94
+ size: str = "1_1",
95
+ is_public: bool = False,
96
+ max_retries: int = 3,
97
+ retry_delay: int = 5
98
+ ) -> List[bytes]:
99
+ """Generate some fire images from your prompt! 🎨
100
+
101
+ Examples:
102
+ >>> provider = FastFluxImager()
103
+ >>> # Basic usage
104
+ >>> images = provider.generate("Cool art")
105
+ >>> # Advanced usage
106
+ >>> images = provider.generate(
107
+ ... prompt="Epic dragon",
108
+ ... amount=2,
109
+ ... model="flux_1_dev",
110
+ ... size="16_9"
111
+ ... )
112
+
113
+ Args:
114
+ prompt (str): Your image description
115
+ amount (int): How many images you want (default: 1)
116
+ model (str): Model to use - check AVAILABLE_MODELS (default: "flux_1_schnell")
117
+ size (str): Image size ratio (default: "1_1")
118
+ is_public (bool): Whether to make the image public (default: False)
119
+ max_retries (int): Max retry attempts if something fails (default: 3)
120
+ retry_delay (int): Seconds to wait between retries (default: 5)
121
+
122
+ Returns:
123
+ List[bytes]: Your generated images
124
+
125
+ Raises:
126
+ ValueError: If the inputs ain't valid
127
+ RequestException: If the API calls fail after retries
128
+ """
129
+ if not prompt:
130
+ raise ValueError("Yo fam, the prompt can't be empty! 🤔")
131
+ if not isinstance(amount, int) or amount < 1:
132
+ raise ValueError("Amount needs to be a positive number! 📈")
133
+ if model not in self.AVAILABLE_MODELS:
134
+ raise ValueError(f"Model must be one of {self.AVAILABLE_MODELS}! 🎯")
135
+ if size not in self.AVAILABLE_SIZES:
136
+ raise ValueError(f"Size must be one of {self.AVAILABLE_SIZES}! 📏")
137
+
138
+ self.prompt = prompt
139
+ response = []
140
+
141
+ # Prepare payload
142
+ payload = {
143
+ "prompt": prompt,
144
+ "model": model,
145
+ "size": size,
146
+ "isPublic": is_public
147
+ }
148
+
149
+ for i in range(amount):
150
+ for attempt in range(max_retries):
151
+ try:
152
+ if self.logging:
153
+ print(f"Generating image {i+1}/{amount}... 🎨")
154
+
155
+ resp = self.session.post(
156
+ self.api_endpoint,
157
+ json=payload,
158
+ timeout=self.timeout
159
+ )
160
+ resp.raise_for_status()
161
+ result = resp.json()
162
+
163
+ if result and 'result' in result:
164
+ # Get base64 data and remove header
165
+ image_data = result['result']
166
+ base64_data = image_data.split(',')[1]
167
+
168
+ # Decode base64 data
169
+ image_bytes = base64.b64decode(base64_data)
170
+ response.append(image_bytes)
171
+
172
+ break
173
+ else:
174
+ raise RequestException("Invalid response format")
175
+
176
+ except RequestException as e:
177
+ if attempt == max_retries - 1:
178
+ raise RequestException(f"Failed to generate image after {max_retries} attempts: {e}")
179
+
180
+ time.sleep(retry_delay)
181
+
182
+ return response
183
+
184
+ def save(
185
+ self,
186
+ response: List[bytes],
187
+ name: Optional[str] = None,
188
+ dir: Optional[Union[str, Path]] = None,
189
+ filenames_prefix: str = "",
190
+ ) -> List[str]:
191
+ """Save your fire generated images! 💾
192
+
193
+ Examples:
194
+ >>> provider = FastFluxImager()
195
+ >>> images = provider.generate("Cool art")
196
+ >>> # Save with default settings
197
+ >>> paths = provider.save(images)
198
+ >>> # Save with custom name and directory
199
+ >>> paths = provider.save(
200
+ ... images,
201
+ ... name="my_art",
202
+ ... dir="my_images",
203
+ ... filenames_prefix="test_"
204
+ ... )
205
+
206
+ Args:
207
+ response (List[bytes]): Your generated images
208
+ name (Optional[str]): Custom name for your images
209
+ dir (Optional[Union[str, Path]]): Where to save the images (default: current directory)
210
+ filenames_prefix (str): Prefix for your image files
211
+
212
+ Returns:
213
+ List[str]: Paths to your saved images
214
+ """
215
+ save_dir = dir if dir else os.getcwd()
216
+ if not os.path.exists(save_dir):
217
+ os.makedirs(save_dir)
218
+
219
+ name = self.prompt if name is None else name
220
+
221
+ # Clean up name for filename use
222
+ safe_name = "".join(c if c.isalnum() or c in "_-" else "_" for c in name)
223
+ safe_name = safe_name[:50] # Truncate if too long
224
+
225
+ filenames = []
226
+
227
+ for i, image in enumerate(response):
228
+ filename = f"{filenames_prefix}{safe_name}_{i}.{self.image_extension}"
229
+ filepath = os.path.join(save_dir, filename)
230
+
231
+ with open(filepath, "wb") as f:
232
+ f.write(image)
233
+
234
+ filenames.append(filename)
235
+
236
+ return filenames
237
+
238
+
239
+ if __name__ == "__main__":
240
+ # Example usage
241
+ provider = FastFluxImager()
242
+ try:
243
+ images = provider.generate("A cyberpunk city at night with neon lights", amount=1)
244
+ paths = provider.save(images, dir="generated_images")
245
+ print(f"Successfully saved images to: {paths}")
246
+ except Exception as e:
247
+ print(f"Oops, something went wrong: {e}")
@@ -1,7 +1,7 @@
1
1
  from .streamElements import *
2
- from .voicepod import *
3
2
  from .parler import *
4
3
  from .deepgram import *
5
4
  from .elevenlabs import *
6
5
  from .murfai import *
7
- from .gesserit import *
6
+ from .gesserit import *
7
+ from .speechma import *
@@ -2,12 +2,11 @@ import time
2
2
  import requests
3
3
  import pathlib
4
4
  import base64
5
+ import tempfile
5
6
  from io import BytesIO
6
- from playsound import playsound
7
7
  from webscout import exceptions
8
8
  from webscout.AIbase import TTSProvider
9
9
  from concurrent.futures import ThreadPoolExecutor, as_completed
10
- from webscout.Litlogger import Logger, LogFormat
11
10
  from webscout.litagent import LitAgent
12
11
  from . import utils
13
12
 
@@ -19,7 +18,6 @@ class DeepgramTTS(TTSProvider):
19
18
  headers: dict[str, str] = {
20
19
  "User-Agent": LitAgent().random()
21
20
  }
22
- cache_dir = pathlib.Path("./audio_cache")
23
21
  all_voices: dict[str, str] = {
24
22
  "Asteria": "aura-asteria-en", "Arcas": "aura-arcas-en", "Luna": "aura-luna-en",
25
23
  "Zeus": "aura-zeus-en", "Orpheus": "aura-orpheus-en", "Angus": "aura-angus-en",
@@ -34,11 +32,7 @@ class DeepgramTTS(TTSProvider):
34
32
  if proxies:
35
33
  self.session.proxies.update(proxies)
36
34
  self.timeout = timeout
37
- self.logger = Logger(
38
- name="DeepgramTTS",
39
- format=LogFormat.MODERN_EMOJI,
40
-
41
- )
35
+ self.temp_dir = tempfile.mkdtemp(prefix="webscout_tts_")
42
36
 
43
37
  def tts(self, text: str, voice: str = "Brian", verbose: bool = True) -> str:
44
38
  """
@@ -62,13 +56,13 @@ class DeepgramTTS(TTSProvider):
62
56
  ), f"Voice '{voice}' not one of [{', '.join(self.all_voices.keys())}]"
63
57
 
64
58
  url = "https://deepgram.com/api/ttsAudioGeneration"
65
- filename = self.cache_dir / f"{int(time.time())}.mp3"
59
+ filename = pathlib.Path(tempfile.mktemp(suffix=".mp3", dir=self.temp_dir))
66
60
 
67
61
  # Split text into sentences using the utils module
68
62
  sentences = utils.split_sentences(text)
69
63
  if verbose:
70
64
  for index, sen in enumerate(sentences):
71
- self.logger.debug(f"Sentence {index}: {sen}")
65
+ print(f"[debug] Sentence {index}: {sen}")
72
66
 
73
67
  def generate_audio_for_chunk(part_text: str, part_number: int):
74
68
  """
@@ -103,15 +97,15 @@ class DeepgramTTS(TTSProvider):
103
97
  if response_data:
104
98
  audio_data = base64.b64decode(response_data)
105
99
  if verbose:
106
- self.logger.success(f"Chunk {part_number} processed successfully 🎉")
100
+ print(f"[debug] Chunk {part_number} processed successfully")
107
101
  return part_number, audio_data
108
102
 
109
103
  if verbose:
110
- self.logger.warning(f"No data received for chunk {part_number}. Attempt {retry_count + 1}/{max_retries} ⚠️")
104
+ print(f"[debug] No data received for chunk {part_number}. Attempt {retry_count + 1}/{max_retries}")
111
105
 
112
106
  except requests.RequestException as e:
113
107
  if verbose:
114
- self.logger.error(f"Error processing chunk {part_number}: {str(e)}. Attempt {retry_count + 1}/{max_retries} 🚨")
108
+ print(f"[debug] Error processing chunk {part_number}: {str(e)}. Attempt {retry_count + 1}/{max_retries}")
115
109
  if retry_count == max_retries - 1:
116
110
  raise
117
111
 
@@ -121,9 +115,6 @@ class DeepgramTTS(TTSProvider):
121
115
  raise RuntimeError(f"Failed to generate audio for chunk {part_number} after {max_retries} attempts")
122
116
 
123
117
  try:
124
- # Create the audio_cache directory if it doesn't exist
125
- self.cache_dir.mkdir(parents=True, exist_ok=True)
126
-
127
118
  # Using ThreadPoolExecutor to handle requests concurrently
128
119
  with ThreadPoolExecutor() as executor:
129
120
  futures = {
@@ -148,36 +139,18 @@ class DeepgramTTS(TTSProvider):
148
139
  f.write(audio_chunks[chunk_num])
149
140
 
150
141
  if verbose:
151
- self.logger.success(f"Audio saved to {filename} 🎉")
142
+ print(f"[debug] Audio saved to {filename}")
152
143
  return str(filename)
153
144
 
154
145
  except Exception as e:
155
- self.logger.critical(f"Failed to generate audio: {str(e)} 🚨")
146
+ print(f"[debug] Failed to generate audio: {str(e)}") if verbose else None
156
147
  raise RuntimeError(f"Failed to generate audio: {str(e)}")
157
148
 
158
- def play_audio(self, filename: str):
159
- """
160
- Plays an audio file using playsound.
161
-
162
- Args:
163
- filename (str): The path to the audio file.
164
-
165
- Raises:
166
- RuntimeError: If there is an error playing the audio.
167
- """
168
- try:
169
- playsound(filename)
170
- except Exception as e:
171
- self.logger.error(f"Failed to play audio: {str(e)} 🚨")
172
- raise RuntimeError(f"Failed to play audio: {str(e)}")
173
-
174
149
  # Example usage
175
150
  if __name__ == "__main__":
176
151
  deepgram = DeepgramTTS()
177
152
  text = "This is a test of the DeepgramTTS text-to-speech API. It supports multiple sentences. Let's see how it works!"
178
153
 
179
- deepgram.logger.info("Generating audio...")
180
- audio_file = deepgram.tts(text, voice="Brian")
181
-
182
- deepgram.logger.info("Playing audio...")
183
- deepgram.play_audio(audio_file)
154
+ print("[debug] Generating audio...")
155
+ audio_file = deepgram.tts(text, voice="Asteria")
156
+ print(f"Audio saved to: {audio_file}")