This repository was archived by the owner on Feb 12, 2026. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtexttospeech.py
More file actions
69 lines (57 loc) · 1.9 KB
/
Copy pathtexttospeech.py
File metadata and controls
69 lines (57 loc) · 1.9 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
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
# ///////////////////////////////////
import subprocess
import sys
def install_package(package_name):
"""Belirtilen paketi yükler."""
subprocess.check_call([sys.executable, "-m", "pip", "install", package_name])
try:
import pyttsx3
except ImportError:
print("Görünüşe göre 'pyttsx3' kütüphanesi yüklenmemiş. Yükleniyor...")
install_package('pyttsx3')
import pyttsx3 # Kütüphaneyi yükledikten sonra tekrar import ediyoruz
# /////////////////////////////////////////////
# Ses motorunu başlat
engine = pyttsx3.init()
# Sesin hızını ve tonunu ayarlama
def ayarla(hiz=150, ton=1.0):
# Hız ayarı
engine.setProperty('rate', hiz)
# Sesin tonu ayarı
engine.setProperty('volume', ton)
# Kullanıcıdan metin alıp sesli yanıt verme fonksiyonu
def seslendirme(text):
engine.say(text)
engine.runAndWait()
# Kullanıcıdan hız ve ton için ayar almak
def kullanici_ayar():
try:
hiz = int(input("Ses hızı (normal: 150): "))
except ValueError:
hiz = 150 # Varsayılan hız
try:
ton = float(input("Ses tonu (normal: 1.0): "))
except ValueError:
ton = 1.0 # Varsayılan ton
ayarla(hiz, ton)
# Ana program döngüsü
def ana_program():
print("Metin-to-Speech (Text-to-Speech) Uygulamasına Hoşgeldiniz!")
while True:
print("\nYapmak istediğiniz işlemi seçin:")
print("1. Seslendirme yap")
print("2. Hız ve ton ayarları")
print("3. Çıkış")
secim = input("Seçiminizi yapın (1/2/3): ")
if secim == '1':
metin = input("Seslendirilmesini istediğiniz metni yazın: ")
seslendirme(metin)
elif secim == '2':
kullanici_ayar()
elif secim == '3':
print("Çıkılıyor...")
break
else:
print("Geçersiz seçenek, tekrar deneyin!")
# Programı başlat
ana_program()