|
@@ -0,0 +1,28 @@
|
|
1
|
+from gtts import gTTS
|
|
2
|
+import pygame
|
|
3
|
+import pytesseract
|
|
4
|
+
|
|
5
|
+pytesseract.pytesseract.tesseract_cmd = 'C:\\Program Files\\Tesseract-OCR\\tesseract'
|
|
6
|
+text = pytesseract.image_to_string('data\\test2.PNG',lang='kor')
|
|
7
|
+print(text)
|
|
8
|
+tts = gTTS(text=text, lang='ko')
|
|
9
|
+tts.save("data\\hello.mp3")
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+music_file = "data\\hello.mp3" # mp3 or mid file
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+freq = 16000 # sampling rate, 44100(CD), 16000(Naver TTS), 24000(google TTS)
|
|
16
|
+bitsize = -16 # signed 16 bit. support 8,-8,16,-16
|
|
17
|
+channels = 1 # 1 is mono, 2 is stereo
|
|
18
|
+buffer = 2048 # number of samples (experiment to get right sound)
|
|
19
|
+
|
|
20
|
+# default : pygame.mixer.init(frequency=22050, size=-16, channels=2, buffer=4096)
|
|
21
|
+pygame.mixer.init(freq, bitsize, channels, buffer)
|
|
22
|
+pygame.mixer.music.load(music_file)
|
|
23
|
+pygame.mixer.music.play()
|
|
24
|
+
|
|
25
|
+clock = pygame.time.Clock()
|
|
26
|
+while pygame.mixer.music.get_busy():
|
|
27
|
+ clock.tick(30)
|
|
28
|
+pygame.mixer.quit()
|