Spaces:
Sleeping
Sleeping
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() | |