version 0.0.15

This commit is contained in:
guanjihuan 2021-07-22 00:15:34 +08:00
parent e000fab086
commit 4f433349ef
3 changed files with 18 additions and 1 deletions

View File

@ -118,6 +118,7 @@ guan.plot_contour(x, y, matrix, xlabel='x', ylabel='y', title='', filename='a',
guan.download_with_scihub(address=None, num=1) guan.download_with_scihub(address=None, num=1)
# audio # audio
guan.str_to_audio(str='hello world', rate=125, voice=1, read=1, save=0, print_text=0)
guan.txt_to_audio(txt_path, rate=125, voice=1, read=1, save=0, print_text=0) guan.txt_to_audio(txt_path, rate=125, voice=1, read=1, save=0, print_text=0)
content = guan.pdf_to_text(pdf_path) content = guan.pdf_to_text(pdf_path)
guan.pdf_to_audio(pdf_path, rate=125, voice=1, read=1, save=0, print_text=0) guan.pdf_to_audio(pdf_path, rate=125, voice=1, read=1, save=0, print_text=0)

View File

@ -1,7 +1,7 @@
[metadata] [metadata]
# replace with your username: # replace with your username:
name = guan name = guan
version = 0.0.14 version = 0.0.15
author = guanjihuan author = guanjihuan
author_email = guanjihuan@163.com author_email = guanjihuan@163.com
description = An open source python package description = An open source python package

View File

@ -2,6 +2,22 @@
# audio # audio
def str_to_audio(str='hello world', rate=125, voice=1, read=1, save=0, print_text=0):
import pyttsx3
if print_text==1:
print(str)
engine = pyttsx3.init()
voices = engine.getProperty('voices')
engine.setProperty('voice', voices[voice].id)
engine.setProperty("rate", rate)
if save==1:
engine.save_to_file(str, 'str.mp3')
engine.runAndWait()
print('MP3 file saved!')
if read==1:
engine.say(str)
engine.runAndWait()
def txt_to_audio(txt_path, rate=125, voice=1, read=1, save=0, print_text=0): def txt_to_audio(txt_path, rate=125, voice=1, read=1, save=0, print_text=0):
import pyttsx3 import pyttsx3
f = open(txt_path, 'r', encoding ='utf-8') f = open(txt_path, 'r', encoding ='utf-8')