samariddin commited on
Commit
287cbe4
1 Parent(s): 57a2a48
.idea/.gitignore ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ # Default ignored files
2
+ /shelf/
3
+ /workspace.xml
.idea/UzGPT-uz.iml ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <module type="PYTHON_MODULE" version="4">
3
+ <component name="NewModuleRootManager">
4
+ <content url="file://$MODULE_DIR$">
5
+ <excludeFolder url="file://$MODULE_DIR$/venv" />
6
+ </content>
7
+ <orderEntry type="jdk" jdkName="Python 3.8 (UzGPT-uz)" jdkType="Python SDK" />
8
+ <orderEntry type="sourceFolder" forTests="false" />
9
+ </component>
10
+ </module>
.idea/inspectionProfiles/Project_Default.xml ADDED
@@ -0,0 +1,16 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <component name="InspectionProjectProfileManager">
2
+ <profile version="1.0">
3
+ <option name="myName" value="Project Default" />
4
+ <inspection_tool class="PyPackageRequirementsInspection" enabled="true" level="WARNING" enabled_by_default="true">
5
+ <option name="ignoredPackages">
6
+ <value>
7
+ <list size="3">
8
+ <item index="0" class="java.lang.String" itemvalue="onnxruntime-gpu" />
9
+ <item index="1" class="java.lang.String" itemvalue="opencv-python" />
10
+ <item index="2" class="java.lang.String" itemvalue="imread-from-url" />
11
+ </list>
12
+ </value>
13
+ </option>
14
+ </inspection_tool>
15
+ </profile>
16
+ </component>
.idea/inspectionProfiles/profiles_settings.xml ADDED
@@ -0,0 +1,6 @@
 
 
 
 
 
 
 
1
+ <component name="InspectionProjectProfileManager">
2
+ <settings>
3
+ <option name="USE_PROJECT_PROFILE" value="false" />
4
+ <version value="1.0" />
5
+ </settings>
6
+ </component>
.idea/misc.xml ADDED
@@ -0,0 +1,4 @@
 
 
 
 
 
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <project version="4">
3
+ <component name="ProjectRootManager" version="2" project-jdk-name="Python 3.8 (UzGPT-uz)" project-jdk-type="Python SDK" />
4
+ </project>
.idea/modules.xml ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <project version="4">
3
+ <component name="ProjectModuleManager">
4
+ <modules>
5
+ <module fileurl="file://$PROJECT_DIR$/.idea/UzGPT-uz.iml" filepath="$PROJECT_DIR$/.idea/UzGPT-uz.iml" />
6
+ </modules>
7
+ </component>
8
+ </project>
.idea/vcs.xml ADDED
@@ -0,0 +1,6 @@
 
 
 
 
 
 
 
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <project version="4">
3
+ <component name="VcsDirectoryMappings">
4
+ <mapping directory="" vcs="Git" />
5
+ </component>
6
+ </project>
app.py ADDED
@@ -0,0 +1,59 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from transformers import pipeline
3
+ from espnet2.bin.tts_inference import Text2Speech
4
+ import warnings
5
+
6
+ warnings.filterwarnings('ignore')
7
+
8
+
9
+ def generateTextAndAudio(inputText, numGen):
10
+ # --- Generating the Text ---
11
+ # With the provided text from user, generate more text up to `numGen` tokens/sub-words
12
+ textOutput = textGenerator(inputText, max_length=numGen)
13
+ # The output of the text generator is a list of dictionaries, grab the first dictionary
14
+ # then get the generated text from the dictionary using the `generated_text` key
15
+ genText = textOutput[0]['generated_text']
16
+
17
+ print("-" * 75)
18
+ print("Input Text:", inputText)
19
+ print("Generated Text:", genText)
20
+ print("-" * 75)
21
+
22
+ # --- Generating the Audio ---
23
+ # With the newly generated text, generate some speech
24
+ audioOutput = audioGenerator(genText)
25
+ # Get the wav data
26
+ genAudio = audioOutput['wav']
27
+
28
+ # Return two things
29
+ # 1) Generated Text
30
+ # 2) 24k sampling rate, and the Generated Audio (wav) as numpy (instead of tensor)
31
+ return genText, (24000, genAudio.numpy())
32
+
33
+
34
+ # Main
35
+ textGenerator = pipeline('text-generation', model='rifkat/GPTuz')
36
+ audioGenerator = Text2Speech.from_pretrained("espnet/kan-bayashi_ljspeech_joint_finetune_conformer_fastspeech2_hifigan")
37
+
38
+ input1_textbox = gr.Textbox(label="Input text")
39
+ input2_slider = gr.Slider(minimum=1, maximum=100, step=1, default=30, label="Number of words to generate")
40
+
41
+ output1_textbox = gr.Textbox(label="Generated Text")
42
+ output2_Audio = gr.Audio(label="Generated Audio")
43
+
44
+ title = "Generate Text and its Audio!"
45
+ description = "Provide the text, and how many subwords to generate"
46
+
47
+ examples = [
48
+ ["Давлат хавфсизлик хизмати", 50],
49
+ ["Давлат хавфсизлик хизмати", 30],
50
+ ["Давлат хавфсизлик хизмати", 60]
51
+ ]
52
+ article = "<p style='text-align: center'><img src='https://visitor-badge.glitch.me/badge?page_id=lilyf_generate_text_and_audio' alt='visitor badge'></p>"
53
+ iface = gr.Interface(fn=generateTextAndAudio,
54
+ inputs=[input1_textbox, input2_slider],
55
+ outputs=[output1_textbox, output2_Audio],
56
+ title=title,
57
+ description=description,
58
+ examples=examples,
59
+ article=article).launch(debug=True)
requirements.txt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ transformers==4.19.2
2
+ gradio==3.0.2
3
+ espnet_model_zoo==0.1.7