Mohssinibra commited on
Commit
6fb8bd2
·
verified ·
1 Parent(s): 4fc2860

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +13 -17
app.py CHANGED
@@ -1,22 +1,18 @@
1
  import gradio as gr
2
- from transformers import pipeline
3
 
4
- # Load the model
5
- model_name = "ychafiqui/whisper-medium-darija"
6
- transcriber = pipeline("automatic-speech-recognition", model=model_name)
 
7
 
8
- def transcribe_audio(audio):
9
- transcription = transcriber(audio)
10
- return transcription['text']
11
-
12
- # Gradio interface
13
- iface = gr.Interface(
14
- fn=transcribe_audio,
15
-
16
- inputs=gr.Audio(type="filepath"),
17
- outputs="text",
18
- title="Darija Audio Transcription",
19
- description="Upload an audio file in Darija to get the transcription."
20
- )
21
 
 
 
22
  iface.launch()
 
1
  import gradio as gr
2
+ from transformers import AutoModelForCausalLM, AutoTokenizer
3
 
4
+ # Charger le modèle et le tokenizer
5
+ model_name = "jondurbin/airoboros-gpt-3.5-turbo-100k-7b"
6
+ tokenizer = AutoTokenizer.from_pretrained(model_name)
7
+ model = AutoModelForCausalLM.from_pretrained(model_name)
8
 
9
+ # Fonction pour générer des réponses
10
+ def generate_response(input_text):
11
+ inputs = tokenizer.encode(input_text, return_tensors="pt")
12
+ outputs = model.generate(inputs, max_length=150)
13
+ response = tokenizer.decode(outputs[0], skip_special_tokens=True)
14
+ return response
 
 
 
 
 
 
 
15
 
16
+ # Interface Gradio
17
+ iface = gr.Interface(fn=generate_response, inputs="text", outputs="text", title="GPT-3.5 Turbo Chatbot")
18
  iface.launch()