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.
- webscout/AIauto.py +191 -176
- webscout/AIbase.py +0 -197
- webscout/AIutel.py +441 -1130
- webscout/DWEBS.py +189 -35
- webscout/{YTdownloader.py → Extra/YTToolkit/YTdownloader.py} +990 -1103
- webscout/Extra/YTToolkit/__init__.py +3 -0
- webscout/{transcriber.py → Extra/YTToolkit/transcriber.py} +479 -551
- webscout/Extra/YTToolkit/ytapi/__init__.py +6 -0
- webscout/Extra/YTToolkit/ytapi/channel.py +307 -0
- webscout/Extra/YTToolkit/ytapi/errors.py +13 -0
- webscout/Extra/YTToolkit/ytapi/extras.py +45 -0
- webscout/Extra/YTToolkit/ytapi/https.py +88 -0
- webscout/Extra/YTToolkit/ytapi/patterns.py +61 -0
- webscout/Extra/YTToolkit/ytapi/playlist.py +59 -0
- webscout/Extra/YTToolkit/ytapi/pool.py +8 -0
- webscout/Extra/YTToolkit/ytapi/query.py +37 -0
- webscout/Extra/YTToolkit/ytapi/stream.py +60 -0
- webscout/Extra/YTToolkit/ytapi/utils.py +62 -0
- webscout/Extra/YTToolkit/ytapi/video.py +102 -0
- webscout/Extra/__init__.py +3 -1
- webscout/Extra/autocoder/__init__.py +9 -0
- webscout/Extra/autocoder/autocoder_utiles.py +121 -0
- webscout/Extra/autocoder/rawdog.py +680 -0
- webscout/Extra/autollama.py +246 -195
- webscout/Extra/gguf.py +81 -56
- webscout/Extra/markdownlite/__init__.py +862 -0
- webscout/Extra/weather_ascii.py +2 -2
- webscout/LLM.py +206 -43
- webscout/Litlogger/__init__.py +681 -0
- webscout/Provider/DARKAI.py +1 -1
- webscout/Provider/EDITEE.py +1 -1
- webscout/Provider/NinjaChat.py +1 -1
- webscout/Provider/PI.py +120 -35
- webscout/Provider/Perplexity.py +590 -598
- webscout/Provider/Reka.py +0 -1
- webscout/Provider/RoboCoders.py +206 -0
- webscout/Provider/TTI/AiForce/__init__.py +22 -0
- webscout/Provider/TTI/AiForce/async_aiforce.py +257 -0
- webscout/Provider/TTI/AiForce/sync_aiforce.py +242 -0
- webscout/Provider/TTI/Nexra/__init__.py +22 -0
- webscout/Provider/TTI/Nexra/async_nexra.py +286 -0
- webscout/Provider/TTI/Nexra/sync_nexra.py +258 -0
- webscout/Provider/TTI/PollinationsAI/__init__.py +23 -0
- webscout/Provider/TTI/PollinationsAI/async_pollinations.py +330 -0
- webscout/Provider/TTI/PollinationsAI/sync_pollinations.py +285 -0
- webscout/Provider/TTI/__init__.py +2 -4
- webscout/Provider/TTI/artbit/__init__.py +22 -0
- webscout/Provider/TTI/artbit/async_artbit.py +184 -0
- webscout/Provider/TTI/artbit/sync_artbit.py +176 -0
- webscout/Provider/TTI/blackbox/__init__.py +4 -0
- webscout/Provider/TTI/blackbox/async_blackbox.py +212 -0
- webscout/Provider/TTI/{blackboximage.py → blackbox/sync_blackbox.py} +199 -153
- webscout/Provider/TTI/deepinfra/__init__.py +4 -0
- webscout/Provider/TTI/deepinfra/async_deepinfra.py +227 -0
- webscout/Provider/TTI/deepinfra/sync_deepinfra.py +199 -0
- webscout/Provider/TTI/huggingface/__init__.py +22 -0
- webscout/Provider/TTI/huggingface/async_huggingface.py +199 -0
- webscout/Provider/TTI/huggingface/sync_huggingface.py +195 -0
- webscout/Provider/TTI/imgninza/__init__.py +4 -0
- webscout/Provider/TTI/imgninza/async_ninza.py +214 -0
- webscout/Provider/TTI/{imgninza.py → imgninza/sync_ninza.py} +209 -136
- webscout/Provider/TTI/talkai/__init__.py +4 -0
- webscout/Provider/TTI/talkai/async_talkai.py +229 -0
- webscout/Provider/TTI/talkai/sync_talkai.py +207 -0
- webscout/Provider/TTS/__init__.py +5 -1
- webscout/Provider/TTS/deepgram.py +183 -0
- webscout/Provider/TTS/elevenlabs.py +137 -0
- webscout/Provider/TTS/gesserit.py +151 -0
- webscout/Provider/TTS/murfai.py +139 -0
- webscout/Provider/TTS/parler.py +134 -107
- webscout/Provider/TTS/streamElements.py +360 -275
- webscout/Provider/TTS/utils.py +280 -0
- webscout/Provider/TTS/voicepod.py +116 -116
- webscout/Provider/__init__.py +8 -1
- webscout/Provider/askmyai.py +2 -2
- webscout/Provider/cerebras.py +227 -219
- webscout/Provider/llama3mitril.py +0 -1
- webscout/Provider/meta.py +794 -779
- webscout/Provider/mhystical.py +176 -0
- webscout/Provider/perplexitylabs.py +265 -0
- webscout/Provider/twitterclone.py +251 -245
- webscout/Provider/typegpt.py +358 -0
- webscout/__init__.py +9 -8
- webscout/__main__.py +5 -5
- webscout/cli.py +252 -280
- webscout/conversation.py +227 -0
- webscout/exceptions.py +161 -29
- webscout/litagent/__init__.py +172 -0
- webscout/litprinter/__init__.py +832 -0
- webscout/optimizers.py +270 -0
- webscout/prompt_manager.py +279 -0
- webscout/scout/__init__.py +11 -0
- webscout/scout/core.py +884 -0
- webscout/scout/element.py +459 -0
- webscout/scout/parsers/__init__.py +69 -0
- webscout/scout/parsers/html5lib_parser.py +172 -0
- webscout/scout/parsers/html_parser.py +236 -0
- webscout/scout/parsers/lxml_parser.py +178 -0
- webscout/scout/utils.py +38 -0
- webscout/swiftcli/__init__.py +810 -0
- webscout/update_checker.py +125 -0
- webscout/version.py +1 -1
- webscout/zeroart/__init__.py +55 -0
- webscout/zeroart/base.py +61 -0
- webscout/zeroart/effects.py +99 -0
- webscout/zeroart/fonts.py +816 -0
- webscout/zerodir/__init__.py +225 -0
- {webscout-6.3.dist-info → webscout-6.5.dist-info}/METADATA +37 -112
- webscout-6.5.dist-info/RECORD +179 -0
- webscout/Agents/Onlinesearcher.py +0 -182
- webscout/Agents/__init__.py +0 -2
- webscout/Agents/functioncall.py +0 -248
- webscout/Bing_search.py +0 -154
- webscout/Provider/TTI/AIuncensoredimage.py +0 -103
- webscout/Provider/TTI/Nexra.py +0 -120
- webscout/Provider/TTI/PollinationsAI.py +0 -138
- webscout/Provider/TTI/WebSimAI.py +0 -142
- webscout/Provider/TTI/aiforce.py +0 -160
- webscout/Provider/TTI/artbit.py +0 -141
- webscout/Provider/TTI/deepinfra.py +0 -148
- webscout/Provider/TTI/huggingface.py +0 -155
- webscout/Provider/TTI/talkai.py +0 -116
- webscout/g4f.py +0 -666
- webscout/models.py +0 -23
- webscout/requestsHTMLfix.py +0 -775
- webscout/webai.py +0 -2590
- webscout-6.3.dist-info/RECORD +0 -124
- {webscout-6.3.dist-info → webscout-6.5.dist-info}/LICENSE.md +0 -0
- {webscout-6.3.dist-info → webscout-6.5.dist-info}/WHEEL +0 -0
- {webscout-6.3.dist-info → webscout-6.5.dist-info}/entry_points.txt +0 -0
- {webscout-6.3.dist-info → webscout-6.5.dist-info}/top_level.txt +0 -0
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
import time
|
|
2
|
+
import requests
|
|
3
|
+
import pathlib
|
|
4
|
+
from io import BytesIO
|
|
5
|
+
from urllib.parse import urlencode
|
|
6
|
+
from playsound import playsound
|
|
7
|
+
from webscout import exceptions
|
|
8
|
+
from webscout.AIbase import TTSProvider
|
|
9
|
+
from webscout.Litlogger import LitLogger, LogFormat, ColorScheme
|
|
10
|
+
from webscout.litagent import LitAgent
|
|
11
|
+
from concurrent.futures import ThreadPoolExecutor, as_completed
|
|
12
|
+
from . import utils
|
|
13
|
+
|
|
14
|
+
class MurfAITTS(TTSProvider):
|
|
15
|
+
"""Text-to-speech provider using the MurfAITTS API."""
|
|
16
|
+
# Request headers
|
|
17
|
+
headers: dict[str, str] = {
|
|
18
|
+
"User-Agent": LitAgent().random()
|
|
19
|
+
}
|
|
20
|
+
cache_dir = pathlib.Path("./audio_cache")
|
|
21
|
+
all_voices: dict[str, str] = {"Hazel": "en-UK-hazel"}
|
|
22
|
+
|
|
23
|
+
def __init__(self, timeout: int = 20, proxies: dict = None):
|
|
24
|
+
"""Initializes the MurfAITTS TTS client."""
|
|
25
|
+
self.session = requests.Session()
|
|
26
|
+
self.session.headers.update(self.headers)
|
|
27
|
+
if proxies:
|
|
28
|
+
self.session.proxies.update(proxies)
|
|
29
|
+
self.timeout = timeout
|
|
30
|
+
self.logger = LitLogger(
|
|
31
|
+
name="MurfAITTS",
|
|
32
|
+
format=LogFormat.MODERN_EMOJI,
|
|
33
|
+
color_scheme=ColorScheme.AURORA
|
|
34
|
+
)
|
|
35
|
+
|
|
36
|
+
def tts(self, text: str, voice: str = "Hazel", verbose:bool = True) -> str:
|
|
37
|
+
"""Converts text to speech using the MurfAITTS API and saves it to a file."""
|
|
38
|
+
assert (
|
|
39
|
+
voice in self.all_voices
|
|
40
|
+
), f"Voice '{voice}' not one of [{', '.join(self.all_voices.keys())}]"
|
|
41
|
+
|
|
42
|
+
filename = self.cache_dir / f"{int(time.time())}.mp3"
|
|
43
|
+
|
|
44
|
+
voice_id = self.all_voices[voice]
|
|
45
|
+
|
|
46
|
+
# Split text into sentences
|
|
47
|
+
sentences = utils.split_sentences(text)
|
|
48
|
+
|
|
49
|
+
# Function to request audio for each chunk
|
|
50
|
+
def generate_audio_for_chunk(part_text: str, part_number: int):
|
|
51
|
+
while True:
|
|
52
|
+
try:
|
|
53
|
+
params: dict[str, str] = {
|
|
54
|
+
"name": voice_id,
|
|
55
|
+
"text": part_text
|
|
56
|
+
}
|
|
57
|
+
encode_param: str = urlencode(params)
|
|
58
|
+
response = self.session.get(f"https://murf.ai/Prod/anonymous-tts/audio?{encode_param}", headers=self.headers, timeout=self.timeout)
|
|
59
|
+
response.raise_for_status()
|
|
60
|
+
|
|
61
|
+
# Create the audio_cache directory if it doesn't exist
|
|
62
|
+
self.cache_dir.mkdir(parents=True, exist_ok=True)
|
|
63
|
+
|
|
64
|
+
# Check if the request was successful
|
|
65
|
+
if response.ok and response.status_code == 200:
|
|
66
|
+
if verbose:
|
|
67
|
+
self.logger.success(f"Chunk {part_number} processed successfully 🎉")
|
|
68
|
+
return part_number, response.content
|
|
69
|
+
else:
|
|
70
|
+
if verbose:
|
|
71
|
+
self.logger.warning(f"No data received for chunk {part_number}. Retrying...")
|
|
72
|
+
except requests.RequestException as e:
|
|
73
|
+
if verbose:
|
|
74
|
+
self.logger.error(f"Error for chunk {part_number}: {e}. Retrying... 🔄")
|
|
75
|
+
time.sleep(1)
|
|
76
|
+
try:
|
|
77
|
+
# Using ThreadPoolExecutor to handle requests concurrently
|
|
78
|
+
with ThreadPoolExecutor() as executor:
|
|
79
|
+
futures = {executor.submit(generate_audio_for_chunk, sentence.strip(), chunk_num): chunk_num
|
|
80
|
+
for chunk_num, sentence in enumerate(sentences, start=1)}
|
|
81
|
+
|
|
82
|
+
# Dictionary to store results with order preserved
|
|
83
|
+
audio_chunks = {}
|
|
84
|
+
|
|
85
|
+
for future in as_completed(futures):
|
|
86
|
+
chunk_num = futures[future]
|
|
87
|
+
try:
|
|
88
|
+
part_number, audio_data = future.result()
|
|
89
|
+
audio_chunks[part_number] = audio_data # Store the audio data in correct sequence
|
|
90
|
+
except Exception as e:
|
|
91
|
+
if verbose:
|
|
92
|
+
self.logger.error(f"Failed to generate audio for chunk {chunk_num}: {e} 🚨")
|
|
93
|
+
|
|
94
|
+
# Combine audio chunks in the correct sequence
|
|
95
|
+
combined_audio = BytesIO()
|
|
96
|
+
for part_number in sorted(audio_chunks.keys()):
|
|
97
|
+
combined_audio.write(audio_chunks[part_number])
|
|
98
|
+
if verbose:
|
|
99
|
+
self.logger.debug(f"Added chunk {part_number} to the combined file.")
|
|
100
|
+
|
|
101
|
+
# Save the combined audio data to a single file
|
|
102
|
+
with open(filename, 'wb') as f:
|
|
103
|
+
f.write(combined_audio.getvalue())
|
|
104
|
+
if verbose:
|
|
105
|
+
self.logger.info(f"Final Audio Saved as {filename} 🔊")
|
|
106
|
+
return filename.as_posix()
|
|
107
|
+
|
|
108
|
+
except requests.exceptions.RequestException as e:
|
|
109
|
+
self.logger.critical(f"Failed to perform the operation: {e} 🚨")
|
|
110
|
+
raise exceptions.FailedToGenerateResponseError(
|
|
111
|
+
f"Failed to perform the operation: {e}"
|
|
112
|
+
)
|
|
113
|
+
|
|
114
|
+
def play_audio(self, filename: str):
|
|
115
|
+
"""
|
|
116
|
+
Plays an audio file using playsound.
|
|
117
|
+
|
|
118
|
+
Args:
|
|
119
|
+
filename (str): The path to the audio file.
|
|
120
|
+
|
|
121
|
+
Raises:
|
|
122
|
+
RuntimeError: If there is an error playing the audio.
|
|
123
|
+
"""
|
|
124
|
+
try:
|
|
125
|
+
playsound(filename)
|
|
126
|
+
except Exception as e:
|
|
127
|
+
self.logger.error(f"Error playing audio: {e} 🔇")
|
|
128
|
+
raise RuntimeError(f"Error playing audio: {e}")
|
|
129
|
+
|
|
130
|
+
# Example usage
|
|
131
|
+
if __name__ == "__main__":
|
|
132
|
+
murfai = MurfAITTS()
|
|
133
|
+
text = "This is a test of the MurfAITTS text-to-speech API. It supports multiple sentences and advanced logging."
|
|
134
|
+
|
|
135
|
+
murfai.logger.info("Generating audio...")
|
|
136
|
+
audio_file = murfai.tts(text, voice="Hazel")
|
|
137
|
+
|
|
138
|
+
murfai.logger.info("Playing audio...")
|
|
139
|
+
murfai.play_audio(audio_file)
|
webscout/Provider/TTS/parler.py
CHANGED
|
@@ -1,108 +1,135 @@
|
|
|
1
|
-
import time
|
|
2
|
-
from pathlib import Path
|
|
3
|
-
from typing import Generator
|
|
4
|
-
from playsound import playsound
|
|
5
|
-
from webscout import exceptions
|
|
6
|
-
from webscout.AIbase import TTSProvider
|
|
7
|
-
|
|
8
|
-
from gradio_client import Client
|
|
9
|
-
import os
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
class ParlerTTS(TTSProvider):
|
|
13
|
-
"""
|
|
14
|
-
A class to interact with the Parler TTS API through Gradio Client.
|
|
15
|
-
"""
|
|
16
|
-
|
|
17
|
-
def __init__(self, timeout: int = 20, proxies: dict = None):
|
|
18
|
-
"""Initializes the Parler TTS client."""
|
|
19
|
-
self.api_endpoint = "/gen_tts"
|
|
20
|
-
self.client = Client("parler-tts/parler_tts") # Initialize the Gradio client
|
|
21
|
-
self.timeout = timeout
|
|
22
|
-
self.audio_cache_dir = Path("./audio_cache")
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
str: The
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
"
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
1
|
+
import time
|
|
2
|
+
from pathlib import Path
|
|
3
|
+
from typing import Generator
|
|
4
|
+
from playsound import playsound
|
|
5
|
+
from webscout import exceptions
|
|
6
|
+
from webscout.AIbase import TTSProvider
|
|
7
|
+
from webscout.Litlogger import LitLogger, LogFormat, ColorScheme
|
|
8
|
+
from gradio_client import Client
|
|
9
|
+
import os
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
class ParlerTTS(TTSProvider):
|
|
13
|
+
"""
|
|
14
|
+
A class to interact with the Parler TTS API through Gradio Client.
|
|
15
|
+
"""
|
|
16
|
+
|
|
17
|
+
def __init__(self, timeout: int = 20, proxies: dict = None):
|
|
18
|
+
"""Initializes the Parler TTS client."""
|
|
19
|
+
self.api_endpoint = "/gen_tts"
|
|
20
|
+
self.client = Client("parler-tts/parler_tts") # Initialize the Gradio client
|
|
21
|
+
self.timeout = timeout
|
|
22
|
+
self.audio_cache_dir = Path("./audio_cache")
|
|
23
|
+
self.logger = LitLogger(
|
|
24
|
+
name="ParlerTTS",
|
|
25
|
+
format=LogFormat.MODERN_EMOJI,
|
|
26
|
+
color_scheme=ColorScheme.AURORA
|
|
27
|
+
)
|
|
28
|
+
|
|
29
|
+
def tts(self, text: str, description: str = "", use_large: bool = False, verbose: bool = True) -> str:
|
|
30
|
+
"""
|
|
31
|
+
Converts text to speech using the Parler TTS API.
|
|
32
|
+
|
|
33
|
+
Args:
|
|
34
|
+
text (str): The text to be converted to speech.
|
|
35
|
+
description (str, optional): Description of the desired voice characteristics. Defaults to "".
|
|
36
|
+
use_large (bool, optional): Whether to use the large model variant. Defaults to False.
|
|
37
|
+
verbose (bool, optional): Whether to log detailed information. Defaults to True.
|
|
38
|
+
|
|
39
|
+
Returns:
|
|
40
|
+
str: The filename of the saved audio file.
|
|
41
|
+
|
|
42
|
+
Raises:
|
|
43
|
+
exceptions.FailedToGenerateResponseError: If there is an error generating or saving the audio.
|
|
44
|
+
"""
|
|
45
|
+
filename = self.audio_cache_dir / f"{int(time.time())}.wav"
|
|
46
|
+
|
|
47
|
+
try:
|
|
48
|
+
if verbose:
|
|
49
|
+
self.logger.info(f"Generating TTS with description: {description} 🎙️")
|
|
50
|
+
|
|
51
|
+
result = self.client.predict(
|
|
52
|
+
text=text,
|
|
53
|
+
description=description,
|
|
54
|
+
use_large=use_large,
|
|
55
|
+
api_name=self.api_endpoint,
|
|
56
|
+
)
|
|
57
|
+
|
|
58
|
+
if isinstance(result, bytes):
|
|
59
|
+
audio_bytes = result
|
|
60
|
+
elif isinstance(result, str) and os.path.isfile(result):
|
|
61
|
+
with open(result, "rb") as f:
|
|
62
|
+
audio_bytes = f.read()
|
|
63
|
+
else:
|
|
64
|
+
raise ValueError(f"Unexpected response from API: {result}")
|
|
65
|
+
|
|
66
|
+
self._save_audio(audio_bytes, filename)
|
|
67
|
+
|
|
68
|
+
if verbose:
|
|
69
|
+
self.logger.success(f"Audio generated successfully: {filename} 🔊")
|
|
70
|
+
|
|
71
|
+
return filename.as_posix()
|
|
72
|
+
|
|
73
|
+
except Exception as e:
|
|
74
|
+
self.logger.critical(f"Error generating audio: {e} 🚨")
|
|
75
|
+
raise exceptions.FailedToGenerateResponseError(
|
|
76
|
+
f"Error generating audio after multiple retries: {e}"
|
|
77
|
+
) from e
|
|
78
|
+
|
|
79
|
+
def _save_audio(self, audio_data: bytes, filename: Path):
|
|
80
|
+
"""
|
|
81
|
+
Saves the audio data to a WAV file in the audio cache directory.
|
|
82
|
+
|
|
83
|
+
Args:
|
|
84
|
+
audio_data (bytes): Audio data to save
|
|
85
|
+
filename (Path): Path to save the audio file
|
|
86
|
+
|
|
87
|
+
Raises:
|
|
88
|
+
exceptions.FailedToGenerateResponseError: If there is an error saving the audio.
|
|
89
|
+
"""
|
|
90
|
+
try:
|
|
91
|
+
self.audio_cache_dir.mkdir(parents=True, exist_ok=True)
|
|
92
|
+
with open(filename, "wb") as f:
|
|
93
|
+
f.write(audio_data)
|
|
94
|
+
self.logger.debug(f"Audio saved to {filename} 💾")
|
|
95
|
+
|
|
96
|
+
except Exception as e:
|
|
97
|
+
self.logger.error(f"Error saving audio: {e} 🔇")
|
|
98
|
+
raise exceptions.FailedToGenerateResponseError(f"Error saving audio: {e}")
|
|
99
|
+
|
|
100
|
+
def play_audio(self, filename: str):
|
|
101
|
+
"""
|
|
102
|
+
Plays an audio file using playsound.
|
|
103
|
+
|
|
104
|
+
Args:
|
|
105
|
+
filename (str): The path to the audio file.
|
|
106
|
+
|
|
107
|
+
Raises:
|
|
108
|
+
RuntimeError: If there is an error playing the audio.
|
|
109
|
+
"""
|
|
110
|
+
try:
|
|
111
|
+
self.logger.info(f"Playing audio: {filename} 🎵")
|
|
112
|
+
playsound(filename)
|
|
113
|
+
except Exception as e:
|
|
114
|
+
self.logger.error(f"Error playing audio: {e} 🔇")
|
|
115
|
+
raise RuntimeError(f"Error playing audio: {e}")
|
|
116
|
+
|
|
117
|
+
|
|
118
|
+
# Example usage
|
|
119
|
+
if __name__ == "__main__":
|
|
120
|
+
parlertts = ParlerTTS()
|
|
121
|
+
text = (
|
|
122
|
+
"All of the data, pre-processing, training code, and weights are released "
|
|
123
|
+
"publicly under a permissive license, enabling the community to build on our work "
|
|
124
|
+
"and develop their own powerful models."
|
|
125
|
+
)
|
|
126
|
+
voice_description = (
|
|
127
|
+
"Laura's voice is monotone yet slightly fast in delivery, with a very close "
|
|
128
|
+
"recording that almost has no background noise."
|
|
129
|
+
)
|
|
130
|
+
|
|
131
|
+
parlertts.logger.info("Generating audio...")
|
|
132
|
+
audio_file = parlertts.tts(text, description=voice_description, use_large=False)
|
|
133
|
+
|
|
134
|
+
parlertts.logger.info("Playing audio...")
|
|
108
135
|
parlertts.play_audio(audio_file)
|