File size: 823 Bytes
adc6d8b
 
 
 
de811b0
adc6d8b
de811b0
be980dd
 
adc6d8b
 
be980dd
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
adc6d8b
 
 
 
 
be980dd
adc6d8b
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
import dotenv
import base64
import os
import requests
import gradio as gr
import PIL
import numpy as np
from scipy.io.wavfile import write
import gradio_client as grc
dotenv.load_dotenv()

client = grc.Client("facebook/seamless_m4t")
def process_image(audio):  
    # audio_name = f"{np.random.randint(0, 100)}.jpg"
    audio_name = f"{1}.wav"
    sr, data = audio
    write(audio_name, sr, data.astype(np.int16))

    out = client.predict(
        "S2TT",
        "file",
        None,
        audio_name,
        "",
        "French",# source language
        "English",# target language
        api_name="/run",
    )
    out = out[1] # get the text
    try :
        return f"{out}"
    except Exception as e :
        return f"{e}"

iface = gr.Interface(fn=process_image, inputs="audio", outputs="text")
iface.launch()