SilvusTV commited on
Commit
e001d2e
1 Parent(s): bf7a308

update all

Browse files
Files changed (4) hide show
  1. app.py +5 -2
  2. language.py +3 -4
  3. requirements.txt +4 -3
  4. text-to-speach.py +19 -0
app.py CHANGED
@@ -1,6 +1,8 @@
1
  from image import *
2
  from language import *
 
3
  import streamlit as st
 
4
 
5
 
6
  # url = "https://i.imgur.com/qs0CxjE_d.webp?maxwidth=760&fidelity=grand"
@@ -14,8 +16,9 @@ url = st.text_input('mettez le liens de votre image')
14
  if st.button('générer'):
15
  responseBase = image(url, question)
16
  st.write('response is :', responseBase)
 
17
  st.write('Part 2')
18
- print(question)
19
  st.write(longText(responseBase, question))
20
 
21
- print('#### TEST 2####')
 
 
1
  from image import *
2
  from language import *
3
+ from translation import *
4
  import streamlit as st
5
+ import os
6
 
7
 
8
  # url = "https://i.imgur.com/qs0CxjE_d.webp?maxwidth=760&fidelity=grand"
 
16
  if st.button('générer'):
17
  responseBase = image(url, question)
18
  st.write('response is :', responseBase)
19
+
20
  st.write('Part 2')
 
21
  st.write(longText(responseBase, question))
22
 
23
+ print("####TEST TTS####")
24
+ os.system("text-to-speach.py")
language.py CHANGED
@@ -3,12 +3,11 @@ from transformers import T5Tokenizer, T5ForConditionalGeneration
3
  def longText(answere, question):
4
  print('###### LANGUAGES ######')
5
 
6
- input_text = " i have a question and answer.\nthe question is : {}\n the response is : {}\n with this information, can you create an answer phrase?".format(question, answere)
7
 
8
  tokenizer = T5Tokenizer.from_pretrained("google/flan-t5-large")
9
- model = T5ForConditionalGeneration.from_pretrained("google/flan-t5-large")
10
- input_ids = tokenizer(input_text, return_tensors="pt").input_ids
11
  outputs = model.generate(input_ids)
12
 
13
- print(tokenizer.decode(outputs[0]))
14
  return tokenizer.decode(outputs[0]).replace("<pad>","").replace("</s>","")
 
3
  def longText(answere, question):
4
  print('###### LANGUAGES ######')
5
 
6
+ input_text = "i have a question and answer.\nthe question is : {}\n the response is : {}\n with this information, can you create an answer phrase?".format(question, answere)
7
 
8
  tokenizer = T5Tokenizer.from_pretrained("google/flan-t5-large")
9
+ model = T5ForConditionalGeneration.from_pretrained("google/flan-t5-large", device_map="auto")
10
+ input_ids = tokenizer(input_text, return_tensors="pt").input_ids.to("cuda")
11
  outputs = model.generate(input_ids)
12
 
 
13
  return tokenizer.decode(outputs[0]).replace("<pad>","").replace("</s>","")
requirements.txt CHANGED
@@ -1,4 +1,5 @@
1
  transformers[torch]
2
- torch
3
- SentencePiece
4
- sacremoses
 
 
1
  transformers[torch]
2
+ sacremoses
3
+ bark
4
+ scipy
5
+ IPython
text-to-speach.py ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from bark import SAMPLE_RATE, generate_audio, preload_models
2
+ from scipy.io.wavfile import write as write_wav
3
+ from IPython.display import Audio
4
+
5
+ # download and load all models
6
+ preload_models()
7
+
8
+ # generate audio from text
9
+ text_prompt = """
10
+ Hello, my name is Suno. And, uh — and I like pizza. [laughs]
11
+ But I also have other interests such as playing tic tac toe.
12
+ """
13
+ audio_array = generate_audio(text_prompt)
14
+
15
+ # save audio to disk
16
+ write_wav("bark_generation.wav", SAMPLE_RATE, audio_array)
17
+
18
+ # play text in notebook
19
+ Audio(audio_array, rate=SAMPLE_RATE)