diff --git a/API_Reference/API_Reference.py b/API_Reference/API_Reference.py index 5bbb72e..5b86c28 100644 --- a/API_Reference/API_Reference.py +++ b/API_Reference/API_Reference.py @@ -243,13 +243,10 @@ guan.plot_contour(x_array, y_array, matrix, xlabel='x', ylabel='y', title='', sh -# preprocessing +# data processing parameter_array = guan.preprocess_for_parallel_calculations(parameter_array_all, cpus=1, task_index=0) - - -# bach processing guan.bach_reading_and_plotting(directory, xlabel='x', ylabel='y') @@ -264,4 +261,6 @@ guan.txt_to_audio(txt_path, rate=125, voice=1, read=1, save=0, print_text=0) content = guan.pdf_to_text(pdf_path) -guan.pdf_to_audio(pdf_path, rate=125, voice=1, read=1, save=0, print_text=0) \ No newline at end of file +guan.pdf_to_audio(pdf_path, rate=125, voice=1, read=1, save=0, print_text=0) + +guan.play_academic_words(bre_or_ame='ame', random_on=0, show_chinese=1, show_link=1, chinese_time=2, rest_time=1) \ No newline at end of file diff --git a/PyPI/setup.cfg b/PyPI/setup.cfg index 86ee9d3..cee2764 100644 --- a/PyPI/setup.cfg +++ b/PyPI/setup.cfg @@ -1,7 +1,7 @@ [metadata] # replace with your username: name = guan -version = 0.0.59 +version = 0.0.62 author = guanjihuan author_email = guanjihuan@163.com description = An open source python package diff --git a/PyPI/src/guan/__init__.py b/PyPI/src/guan/__init__.py index d6ae0dd..36d210d 100644 --- a/PyPI/src/guan/__init__.py +++ b/PyPI/src/guan/__init__.py @@ -2,20 +2,19 @@ # Modules -# # Module 1: basic_functions -# # Module 2: Fourier_transform -# # Module 3: Hamiltonian_of_finite_size_systems -# # Module 4: Hamiltonian_of_models_in_the_reciprocal_space -# # Module 5: band_structures_and_wave_functions -# # Module 6: Green_functions -# # Module 7: density_of_states -# # Module 8: quantum_transport -# # Module 9: topological_invariant -# # Module 10: read_and_write -# # Module 11: plot_figures -# # Module 12: preprocess -# # Module 13: bach processing -# # Module 14: others +# # Module 1: basic functions +# # Module 2: Fourier transform +# # Module 3: Hamiltonian of finite size systems +# # Module 4: Hamiltonian of models in the reciprocal space +# # Module 5: band structures and wave functions +# # Module 6: Green functions +# # Module 7: density of states +# # Module 8: quantum transport +# # Module 9: topological invariant +# # Module 10: read and write +# # Module 11: plot figures +# # Module 12: data processing +# # Module 13: others # import packages @@ -107,7 +106,7 @@ def sigma_zz(): # Module 2: Fourier_transform -# Fourier_transform for discrete lattices +# Fourier transform for discrete lattices def one_dimensional_fourier_transform(k, unit_cell, hopping): unit_cell = np.array(unit_cell) @@ -464,7 +463,7 @@ def hamiltonian_of_one_QAH_model(k1, k2, t1=1, t2=1, t3=0.5, m=-1): -# Module 5: band_structures_and_wave_functions +# Module 5: band structures and wave functions ## band structures @@ -1545,7 +1544,7 @@ def plot_contour(x_array, y_array, matrix, xlabel='x', ylabel='y', title='', sho -# Module 12: preprocessing +# Module 12: data processing def preprocess_for_parallel_calculations(parameter_array_all, cpus=1, task_index=0): num_all = np.array(parameter_array_all).shape[0] @@ -1560,17 +1559,6 @@ def preprocess_for_parallel_calculations(parameter_array_all, cpus=1, task_index parameter_array = parameter_array_all[task_index*num_parameter:num_all] return parameter_array - - - - - - - - - -# Module 13: bach processing - def bach_reading_and_plotting(directory, xlabel='x', ylabel='y'): import re import os @@ -1588,7 +1576,7 @@ def bach_reading_and_plotting(directory, xlabel='x', ylabel='y'): -# Module 14: others +# Module 13: others ## download @@ -1713,4 +1701,61 @@ def pdf_to_audio(pdf_path, rate=125, voice=1, read=1, save=0, print_text=0): print('MP3 file saved!') if read==1: engine.say(text) - engine.runAndWait() \ No newline at end of file + engine.runAndWait() + +def play_academic_words(bre_or_ame='ame', random_on=0, show_chinese=1, show_link=1, chinese_time=2, rest_time=1): + from bs4 import BeautifulSoup + import re + import urllib.request + import requests + import os + import pygame + import time + import ssl + import random + ssl._create_default_https_context = ssl._create_unverified_context + html = urllib.request.urlopen("https://www.guanjihuan.com/archives/4418").read().decode('utf-8') + if bre_or_ame == 'ame': + directory = 'words_mp3_ameProns/' + elif bre_or_ame == 'bre': + directory = 'words_mp3_breProns/' + exist_directory = os.path.exists(directory) + html_file = urllib.request.urlopen("https://file.guanjihuan.com/words/"+directory).read().decode('utf-8') + if exist_directory == 0: + os.makedirs(directory) + soup = BeautifulSoup(html, features='lxml') + contents = re.findall('
.*?
', content, re.S)[0][3:-4] + time.sleep(chinese_time) + if show_chinese==1: + print(translation) + time.sleep(rest_time) + pygame.mixer.music.stop() + except: + pass + print() \ No newline at end of file