File size: 1,171 Bytes
4143489
 
 
 
 
 
dbcc3a3
 
 
4143489
dbcc3a3
 
 
4143489
dbcc3a3
4143489
 
 
57f9f74
4143489
 
dbcc3a3
4143489
 
 
 
 
f57ce64
4143489
 
 
 
 
ea78544
4143489
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
import gradio as gr
from pydub import AudioSegment
import os
from typing import Union
from ai_functions import MONDJEMIN_AI  # Assurez-vous que ce module est correctement importé et accessible

# def segment_sentence(sentence, word_limit):
#     words = sentence.split()
#     segments = []

#     for i in range(0, len(words), word_limit):
#         segment = ' '.join(words[i:i + word_limit])
#         segments.append(segment)

#     return segments

def process_audio(file):
    
    ai = MONDJEMIN_AI(file)
    source_sentence = ai.transcriptor()

    sentences = source_sentence.split(',')
    traduction = ai.translate(sentences)
    
    return source_sentence, traduction

def main(audio):
    print(audio)
    transcription, traduction = process_audio(audio)
    return transcription, traduction

interface = gr.Interface(
    fn=main,
    inputs=gr.Audio(type = "filepath"),
    outputs=[gr.Textbox(label="Transcription"), gr.Textbox(label="Traduction")],
    title="Transcription Audio",
    description="Chargez un fichier audio ou enregistrez directement à partir de votre microphone pour obtenir la transcription et la traduction."
)

interface.launch()