version 0.0.11
This commit is contained in:
parent
37b196377f
commit
cd3db00afe
@ -118,6 +118,6 @@ 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.txt_to_audio(txt_path, rate=125, voice_type_0_or_1=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_type_0_or_1=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)
|
@ -1,7 +1,7 @@
|
|||||||
[metadata]
|
[metadata]
|
||||||
# replace with your username:
|
# replace with your username:
|
||||||
name = guan
|
name = guan
|
||||||
version = 0.0.10
|
version = 0.0.11
|
||||||
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
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
# audio
|
# audio
|
||||||
|
|
||||||
def txt_to_audio(txt_path, rate=125, voice_type_0_or_1=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')
|
||||||
text = f.read()
|
text = f.read()
|
||||||
@ -10,7 +10,7 @@ def txt_to_audio(txt_path, rate=125, voice_type_0_or_1=1, read=1, save=0, print_
|
|||||||
print(text)
|
print(text)
|
||||||
engine = pyttsx3.init()
|
engine = pyttsx3.init()
|
||||||
voices = engine.getProperty('voices')
|
voices = engine.getProperty('voices')
|
||||||
engine.setProperty('voice', voices[voice_type_0_or_1].id)
|
engine.setProperty('voice', voices[voice].id)
|
||||||
engine.setProperty("rate", rate)
|
engine.setProperty("rate", rate)
|
||||||
if save==1:
|
if save==1:
|
||||||
import re
|
import re
|
||||||
@ -52,14 +52,14 @@ def pdf_to_text(pdf_path):
|
|||||||
content = content + x.get_text().strip()
|
content = content + x.get_text().strip()
|
||||||
return content
|
return content
|
||||||
|
|
||||||
def pdf_to_audio(pdf_path, rate=125, voice_type_0_or_1=1, read=1, save=0, print_text=0):
|
def pdf_to_audio(pdf_path, rate=125, voice=1, read=1, save=0, print_text=0):
|
||||||
import pyttsx3
|
import pyttsx3
|
||||||
text = pdf_to_text(pdf_path)
|
text = pdf_to_text(pdf_path)
|
||||||
if print_text==1:
|
if print_text==1:
|
||||||
print(text)
|
print(text)
|
||||||
engine = pyttsx3.init()
|
engine = pyttsx3.init()
|
||||||
voices = engine.getProperty('voices')
|
voices = engine.getProperty('voices')
|
||||||
engine.setProperty('voice', voices[voice_type_0_or_1].id)
|
engine.setProperty('voice', voices[voice].id)
|
||||||
engine.setProperty("rate", rate)
|
engine.setProperty("rate", rate)
|
||||||
if save==1:
|
if save==1:
|
||||||
import re
|
import re
|
||||||
|
Loading…
x
Reference in New Issue
Block a user