pyrospeak 0.0.1__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.
- pyrospeak-0.0.1/PKG-INFO +73 -0
- pyrospeak-0.0.1/README.md +55 -0
- pyrospeak-0.0.1/pyproject.toml +28 -0
- pyrospeak-0.0.1/pyrospeak/__init__.py +4 -0
- pyrospeak-0.0.1/pyrospeak/stt.py +63 -0
- pyrospeak-0.0.1/pyrospeak/tts.py +83 -0
- pyrospeak-0.0.1/pyrospeak.egg-info/PKG-INFO +73 -0
- pyrospeak-0.0.1/pyrospeak.egg-info/SOURCES.txt +10 -0
- pyrospeak-0.0.1/pyrospeak.egg-info/dependency_links.txt +1 -0
- pyrospeak-0.0.1/pyrospeak.egg-info/requires.txt +8 -0
- pyrospeak-0.0.1/pyrospeak.egg-info/top_level.txt +1 -0
- pyrospeak-0.0.1/setup.cfg +4 -0
pyrospeak-0.0.1/PKG-INFO
ADDED
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: pyrospeak
|
|
3
|
+
Version: 0.0.1
|
|
4
|
+
Summary: Simple TTS & STT wrapper with multiple engines
|
|
5
|
+
Author: Mureșan Robert
|
|
6
|
+
License: MIT
|
|
7
|
+
Project-URL: Homepage, https://github.com/Robertinoos13/PyroSpeak-Library
|
|
8
|
+
Requires-Python: >=3.9
|
|
9
|
+
Description-Content-Type: text/markdown
|
|
10
|
+
Requires-Dist: pyttsx3
|
|
11
|
+
Requires-Dist: gTTS
|
|
12
|
+
Requires-Dist: pygame
|
|
13
|
+
Requires-Dist: numpy
|
|
14
|
+
Requires-Dist: sounddevice
|
|
15
|
+
Requires-Dist: whisper
|
|
16
|
+
Requires-Dist: faststt
|
|
17
|
+
Requires-Dist: elevenlabs
|
|
18
|
+
|
|
19
|
+
# `PyroSpeak` 🗣️
|
|
20
|
+
|
|
21
|
+
`PyroSpeak` is a simple and flexible Python library for Text-to-Speech (TTS) and Speech-to-Text (STT), designed to work with multiple engines, both online and offline, using a clean and beginner-friendly API.
|
|
22
|
+
|
|
23
|
+
It aims to provide a single, unified interface for common speech tasks without forcing you to deal with low-level audio details.
|
|
24
|
+
|
|
25
|
+
## Features
|
|
26
|
+
|
|
27
|
+
- Multiple TTS engines (online & offline)
|
|
28
|
+
- Multiple STT engines (FastSTT, Whisper)
|
|
29
|
+
- Minimal and intuitive API
|
|
30
|
+
- Suitable for experiments, bots, and small AI projects
|
|
31
|
+
- Works well with real-time audio
|
|
32
|
+
|
|
33
|
+
## Quick Example
|
|
34
|
+
``` python
|
|
35
|
+
from pyrospeak import speak, record
|
|
36
|
+
|
|
37
|
+
# Text to Speech
|
|
38
|
+
speak("Hello world!", engine="gtts")
|
|
39
|
+
|
|
40
|
+
# Speech to Text
|
|
41
|
+
text = record(engine="whisper")
|
|
42
|
+
print(text)
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
## Supported Engines
|
|
46
|
+
### Text-to-Speech (TTS)
|
|
47
|
+
|
|
48
|
+
- gTTS (Google Text-to-Speech)
|
|
49
|
+
- pyttsx3 (offline)
|
|
50
|
+
- ElevenLabs (API-based)
|
|
51
|
+
|
|
52
|
+
### Speech-to-Text (STT)
|
|
53
|
+
|
|
54
|
+
- FastSTT
|
|
55
|
+
- Whisper (OpenAI)
|
|
56
|
+
|
|
57
|
+
---
|
|
58
|
+
|
|
59
|
+
## Configuration
|
|
60
|
+
|
|
61
|
+
Most functions are configurable through keyword arguments such as:
|
|
62
|
+
- engine
|
|
63
|
+
- language
|
|
64
|
+
- model size / device
|
|
65
|
+
- time limits
|
|
66
|
+
|
|
67
|
+
Refer to the source code for full parameter lists.
|
|
68
|
+
|
|
69
|
+
|
|
70
|
+
## License
|
|
71
|
+
|
|
72
|
+
MIT License
|
|
73
|
+
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
# `PyroSpeak` 🗣️
|
|
2
|
+
|
|
3
|
+
`PyroSpeak` is a simple and flexible Python library for Text-to-Speech (TTS) and Speech-to-Text (STT), designed to work with multiple engines, both online and offline, using a clean and beginner-friendly API.
|
|
4
|
+
|
|
5
|
+
It aims to provide a single, unified interface for common speech tasks without forcing you to deal with low-level audio details.
|
|
6
|
+
|
|
7
|
+
## Features
|
|
8
|
+
|
|
9
|
+
- Multiple TTS engines (online & offline)
|
|
10
|
+
- Multiple STT engines (FastSTT, Whisper)
|
|
11
|
+
- Minimal and intuitive API
|
|
12
|
+
- Suitable for experiments, bots, and small AI projects
|
|
13
|
+
- Works well with real-time audio
|
|
14
|
+
|
|
15
|
+
## Quick Example
|
|
16
|
+
``` python
|
|
17
|
+
from pyrospeak import speak, record
|
|
18
|
+
|
|
19
|
+
# Text to Speech
|
|
20
|
+
speak("Hello world!", engine="gtts")
|
|
21
|
+
|
|
22
|
+
# Speech to Text
|
|
23
|
+
text = record(engine="whisper")
|
|
24
|
+
print(text)
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
## Supported Engines
|
|
28
|
+
### Text-to-Speech (TTS)
|
|
29
|
+
|
|
30
|
+
- gTTS (Google Text-to-Speech)
|
|
31
|
+
- pyttsx3 (offline)
|
|
32
|
+
- ElevenLabs (API-based)
|
|
33
|
+
|
|
34
|
+
### Speech-to-Text (STT)
|
|
35
|
+
|
|
36
|
+
- FastSTT
|
|
37
|
+
- Whisper (OpenAI)
|
|
38
|
+
|
|
39
|
+
---
|
|
40
|
+
|
|
41
|
+
## Configuration
|
|
42
|
+
|
|
43
|
+
Most functions are configurable through keyword arguments such as:
|
|
44
|
+
- engine
|
|
45
|
+
- language
|
|
46
|
+
- model size / device
|
|
47
|
+
- time limits
|
|
48
|
+
|
|
49
|
+
Refer to the source code for full parameter lists.
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
## License
|
|
53
|
+
|
|
54
|
+
MIT License
|
|
55
|
+
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["setuptools>=61.0"]
|
|
3
|
+
build-backend = "setuptools.build_meta"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "pyrospeak"
|
|
7
|
+
version = "0.0.1"
|
|
8
|
+
description = "Simple TTS & STT wrapper with multiple engines"
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
requires-python = ">=3.9"
|
|
11
|
+
license = {text = "MIT"}
|
|
12
|
+
authors = [
|
|
13
|
+
{name = "Mureșan Robert"}
|
|
14
|
+
]
|
|
15
|
+
|
|
16
|
+
dependencies = [
|
|
17
|
+
"pyttsx3",
|
|
18
|
+
"gTTS",
|
|
19
|
+
"pygame",
|
|
20
|
+
"numpy",
|
|
21
|
+
"sounddevice",
|
|
22
|
+
"whisper",
|
|
23
|
+
"faststt",
|
|
24
|
+
"elevenlabs"
|
|
25
|
+
]
|
|
26
|
+
|
|
27
|
+
[project.urls]
|
|
28
|
+
Homepage = "https://github.com/Robertinoos13/PyroSpeak-Library"
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import os
|
|
2
|
+
os.environ.setdefault('KMP_DUPLICATE_LIB_OK', 'TRUE')
|
|
3
|
+
os.environ.setdefault('HF_HUB_DISABLE_SYMLINKS_WARNING', '1')
|
|
4
|
+
|
|
5
|
+
# STT Modules
|
|
6
|
+
from faststt import FastSTT
|
|
7
|
+
import whisper
|
|
8
|
+
|
|
9
|
+
# Other Modules
|
|
10
|
+
import logging
|
|
11
|
+
import sounddevice as sd
|
|
12
|
+
import numpy as np
|
|
13
|
+
|
|
14
|
+
def record(engine="faststt",
|
|
15
|
+
faststt_model_size="base",
|
|
16
|
+
faststt_device="CPU",
|
|
17
|
+
faststt_timeout=3,
|
|
18
|
+
faststt_phrase_time_limit=5,
|
|
19
|
+
whisper_seconds=5,
|
|
20
|
+
whisper_samplerate=16000,
|
|
21
|
+
whisper_name="base",
|
|
22
|
+
whisper_device="cpu"):
|
|
23
|
+
|
|
24
|
+
# FastSTT code
|
|
25
|
+
if engine.lower() in ("faststt"):
|
|
26
|
+
|
|
27
|
+
logging.basicConfig(level=logging.INFO)
|
|
28
|
+
|
|
29
|
+
stt = FastSTT(
|
|
30
|
+
model_size=faststt_model_size.lower(),
|
|
31
|
+
device=faststt_device.lower()
|
|
32
|
+
)
|
|
33
|
+
|
|
34
|
+
print("Listening...")
|
|
35
|
+
|
|
36
|
+
try:
|
|
37
|
+
text = stt.listen_and_transcribe(timeout=faststt_timeout, phrase_time_limit=faststt_phrase_time_limit)
|
|
38
|
+
if text and isinstance(text, dict):
|
|
39
|
+
print("Transcription:", text["text"])
|
|
40
|
+
else:
|
|
41
|
+
print("...no speech detected")
|
|
42
|
+
|
|
43
|
+
except KeyboardInterrupt:
|
|
44
|
+
print("\nStopped by user")
|
|
45
|
+
|
|
46
|
+
except Exception as e:
|
|
47
|
+
pass
|
|
48
|
+
|
|
49
|
+
result = text
|
|
50
|
+
return result["text"] if isinstance(result, dict) else result
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
# Whisper code
|
|
54
|
+
elif engine.lower() in ("whisper"):
|
|
55
|
+
print(f"Listening for {whisper_seconds} seconds. Speak...")
|
|
56
|
+
model = whisper.load_model(name=whisper_name.lower(), device=whisper_device.lower())
|
|
57
|
+
|
|
58
|
+
# Înregistrare direct în memorie: float32 (formatul cerut de Whisper)
|
|
59
|
+
audio = sd.rec(int(whisper_seconds * whisper_samplerate), samplerate=whisper_samplerate, channels=1, dtype=np.float32)
|
|
60
|
+
sd.wait() # Așteaptă finalizarea înregistrării
|
|
61
|
+
|
|
62
|
+
# Transcrierea directă a array-ului aplatizat (1D)
|
|
63
|
+
return model.transcribe(audio.flatten())["text"]
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import os
|
|
2
|
+
os.environ.setdefault('KMP_DUPLICATE_LIB_OK', 'TRUE')
|
|
3
|
+
os.environ.setdefault('HF_HUB_DISABLE_SYMLINKS_WARNING', '1')
|
|
4
|
+
|
|
5
|
+
# TTS Modules
|
|
6
|
+
import pyttsx3
|
|
7
|
+
from gtts import gTTS
|
|
8
|
+
from elevenlabs.client import ElevenLabs
|
|
9
|
+
from elevenlabs import stream
|
|
10
|
+
|
|
11
|
+
# Other
|
|
12
|
+
import pygame
|
|
13
|
+
import tempfile
|
|
14
|
+
import os
|
|
15
|
+
import sys
|
|
16
|
+
import io
|
|
17
|
+
|
|
18
|
+
try:
|
|
19
|
+
sys.stdout.reconfigure(encoding='utf-8')
|
|
20
|
+
except Exception:
|
|
21
|
+
# Fallback pentru versiuni Python mai învechite
|
|
22
|
+
try:
|
|
23
|
+
sys.stdout = io.TextIOWrapper(sys.stdout.buffer, encoding='utf-8', errors='replace')
|
|
24
|
+
except Exception:
|
|
25
|
+
pass
|
|
26
|
+
|
|
27
|
+
def speak(text_to_procces="",
|
|
28
|
+
engine="gtts",
|
|
29
|
+
language='en',
|
|
30
|
+
elevenlabs_api_key="",
|
|
31
|
+
elevenlabs_voice_id='21m00Tcm4TlvDq8ikWAM',
|
|
32
|
+
elevenlabs_model_id='eleven_multilingual_v2'):
|
|
33
|
+
|
|
34
|
+
# gTTS code
|
|
35
|
+
if engine.lower() in ("gtts", 'google', 'free_online'):
|
|
36
|
+
|
|
37
|
+
with tempfile.NamedTemporaryFile(delete=False, suffix='.mp3') as fp:
|
|
38
|
+
if language.lower() == 'auto':
|
|
39
|
+
tts = gTTS(
|
|
40
|
+
text=text_to_procces,
|
|
41
|
+
lang_check=True
|
|
42
|
+
)
|
|
43
|
+
|
|
44
|
+
else:
|
|
45
|
+
tts = gTTS(
|
|
46
|
+
text=text_to_procces,
|
|
47
|
+
lang=language
|
|
48
|
+
)
|
|
49
|
+
|
|
50
|
+
tts.save(fp.name)
|
|
51
|
+
|
|
52
|
+
pygame.mixer.init()
|
|
53
|
+
pygame.mixer.music.load(fp.name)
|
|
54
|
+
pygame.mixer.music.play()
|
|
55
|
+
while pygame.mixer.music.get_busy():
|
|
56
|
+
pass
|
|
57
|
+
|
|
58
|
+
pygame.mixer.music.stop()
|
|
59
|
+
pygame.mixer.quit()
|
|
60
|
+
os.unlink(fp.name)
|
|
61
|
+
|
|
62
|
+
|
|
63
|
+
# ElevenLabs code
|
|
64
|
+
elif engine.lower() in ("elevenlabs", "pay_online", "eleven labs"):
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
client = ElevenLabs(api_key=elevenlabs_api_key)
|
|
68
|
+
|
|
69
|
+
audio_stream = client.text_to_speech.stream(
|
|
70
|
+
text=text_to_procces,
|
|
71
|
+
voice_id=elevenlabs_voice_id,
|
|
72
|
+
model_id=elevenlabs_model_id
|
|
73
|
+
)
|
|
74
|
+
|
|
75
|
+
stream(audio_stream)
|
|
76
|
+
|
|
77
|
+
|
|
78
|
+
# pyttsx3 code
|
|
79
|
+
elif engine.lower() in ("pyttsx3", "offline", "free offline"):
|
|
80
|
+
|
|
81
|
+
engine_pyttsx3 = pyttsx3.init()
|
|
82
|
+
engine_pyttsx3.say(text_to_procces)
|
|
83
|
+
engine_pyttsx3.runAndWait()
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: pyrospeak
|
|
3
|
+
Version: 0.0.1
|
|
4
|
+
Summary: Simple TTS & STT wrapper with multiple engines
|
|
5
|
+
Author: Mureșan Robert
|
|
6
|
+
License: MIT
|
|
7
|
+
Project-URL: Homepage, https://github.com/Robertinoos13/PyroSpeak-Library
|
|
8
|
+
Requires-Python: >=3.9
|
|
9
|
+
Description-Content-Type: text/markdown
|
|
10
|
+
Requires-Dist: pyttsx3
|
|
11
|
+
Requires-Dist: gTTS
|
|
12
|
+
Requires-Dist: pygame
|
|
13
|
+
Requires-Dist: numpy
|
|
14
|
+
Requires-Dist: sounddevice
|
|
15
|
+
Requires-Dist: whisper
|
|
16
|
+
Requires-Dist: faststt
|
|
17
|
+
Requires-Dist: elevenlabs
|
|
18
|
+
|
|
19
|
+
# `PyroSpeak` 🗣️
|
|
20
|
+
|
|
21
|
+
`PyroSpeak` is a simple and flexible Python library for Text-to-Speech (TTS) and Speech-to-Text (STT), designed to work with multiple engines, both online and offline, using a clean and beginner-friendly API.
|
|
22
|
+
|
|
23
|
+
It aims to provide a single, unified interface for common speech tasks without forcing you to deal with low-level audio details.
|
|
24
|
+
|
|
25
|
+
## Features
|
|
26
|
+
|
|
27
|
+
- Multiple TTS engines (online & offline)
|
|
28
|
+
- Multiple STT engines (FastSTT, Whisper)
|
|
29
|
+
- Minimal and intuitive API
|
|
30
|
+
- Suitable for experiments, bots, and small AI projects
|
|
31
|
+
- Works well with real-time audio
|
|
32
|
+
|
|
33
|
+
## Quick Example
|
|
34
|
+
``` python
|
|
35
|
+
from pyrospeak import speak, record
|
|
36
|
+
|
|
37
|
+
# Text to Speech
|
|
38
|
+
speak("Hello world!", engine="gtts")
|
|
39
|
+
|
|
40
|
+
# Speech to Text
|
|
41
|
+
text = record(engine="whisper")
|
|
42
|
+
print(text)
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
## Supported Engines
|
|
46
|
+
### Text-to-Speech (TTS)
|
|
47
|
+
|
|
48
|
+
- gTTS (Google Text-to-Speech)
|
|
49
|
+
- pyttsx3 (offline)
|
|
50
|
+
- ElevenLabs (API-based)
|
|
51
|
+
|
|
52
|
+
### Speech-to-Text (STT)
|
|
53
|
+
|
|
54
|
+
- FastSTT
|
|
55
|
+
- Whisper (OpenAI)
|
|
56
|
+
|
|
57
|
+
---
|
|
58
|
+
|
|
59
|
+
## Configuration
|
|
60
|
+
|
|
61
|
+
Most functions are configurable through keyword arguments such as:
|
|
62
|
+
- engine
|
|
63
|
+
- language
|
|
64
|
+
- model size / device
|
|
65
|
+
- time limits
|
|
66
|
+
|
|
67
|
+
Refer to the source code for full parameter lists.
|
|
68
|
+
|
|
69
|
+
|
|
70
|
+
## License
|
|
71
|
+
|
|
72
|
+
MIT License
|
|
73
|
+
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
README.md
|
|
2
|
+
pyproject.toml
|
|
3
|
+
pyrospeak/__init__.py
|
|
4
|
+
pyrospeak/stt.py
|
|
5
|
+
pyrospeak/tts.py
|
|
6
|
+
pyrospeak.egg-info/PKG-INFO
|
|
7
|
+
pyrospeak.egg-info/SOURCES.txt
|
|
8
|
+
pyrospeak.egg-info/dependency_links.txt
|
|
9
|
+
pyrospeak.egg-info/requires.txt
|
|
10
|
+
pyrospeak.egg-info/top_level.txt
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
pyrospeak
|