Python ile saat ve tarih bilgisini sese çevirebilmek için küçük bir uygulama yazdım.
Öncelikle;
pendulum ve pyttsx3 modüllerinin yüklü olması gerekmekte. Eğer yüklü değilse;
|
1 |
pip install pendulum pyttsx3 |
ile kuralım.
|
1 2 3 4 |
import pyttsx3 engine = pyttsx3.init() engine.say("Mehmet") engine.runAndWait() |
ile de test yapalım. Linux için “libespeak.so.1: cannot open shared object file: No such file or directory” hatası aldım. “espeak” paketi kurulu değilmiş.
|
1 |
sudo dnf install espeak -y |
bu şekilde kurulumu yaptım ve tekrar kontrol ettim. Sıkıntı olmadı.
Zamanı duyabilmek için alttaki kodları kullandım:
|
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 |
""" Mehmet Bilgi 31-01-2021 https://www.instagram.com/p/CKodfdlAKKf/ Yukarıdaki linkteki bilgilerden düzenlenmiştir. Eğer; libespeak.so.1: cannot open shared object file: No such file or directory hatası verirse Linux espeak paketini kur MS Win için sapi5 Mac için nsss """ import pendulum import pyttsx3 #"espeak" için dil = 64 engine = pyttsx3.init() engine.setProperty("rate", 120) #konuşma hızı voices = engine.getProperty('voices') engine.setProperty('voice', voices[dil].id) #Türkçe #Konuşma fonksiyonu def speak(text): engine.say(text) engine.runAndWait() t = {"01":"Ocak", "02":"Şubat", "03":"Mart", "04":"Nisan", "05":"Mayıs", "06":"Haziran", "07":"Temmuz", "08":"Ağustos", "09":"Eylül", "10":"Ekim", "11":"Kasım", "12":"Aralık"} d1 = pendulum.now() #Anlık zaman #Zaman bilgisini parçala dt1 = str(d1).split(".") z1 = dt1[0].split("T") tarih = z1[0].split("-") zaman = z1[1].split(":") saat = str(int(zaman[0])) dakika = zaman[1] gun = str(int(tarih[2])) ay1 = tarih[1] ay = t.get(ay1) yil = str(int(tarih[0])) yer1 = d1.timezone_name.split("/")[1]#Europe/Istanbul kısmı parcalandı y = yer1 + " için" s = "Saat " + saat + " " + dakika t = "Tarih " + gun + " " + ay + " " + yil print(y) speak(y) print(s) speak(s) print(t) speak(t) engine.stop() |
Kaynak:
https://www.instagram.com/p/CKodfdlAKKf/
7 segment 7segment 12F675 12F683 16F877A ADC Arduino AVR blue pill BUTON button Code Composer Studio Direnç esp esp8266 G2552 led Linux LIS3DSH LIS302DL micropython MSP430 ortanca filtre PIC port PWM PySimpleGUI Python pyttsx3 seri port seven segment SPI STM32 STM32F-Discovery STM32F4-DISCO STM32F4-Discovery STM32F407 Thonny Timer0 UART usb USB-TTL dönüştürücü Voltmetre Zener test cihazı İvme Sensörü
