File size: 1,108 Bytes
4dff2f5
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
from datetime import datetime
import gradio as gr
from dotenv import load_dotenv
from gradio_client import Client  # Gradio client for Hugging Face models

def main():
    """
    Calls Gradio app hosted on Hugging Face using Gradio client.
    """
    load_dotenv() # Load .env file for HF token if needed


    try:
        client = Client("samir72/AudioChatTranscriber")  # Hugging Face model with Gradio app
        #client.view_api()  # View available API endpoints
        response = client.predict(
			upload_path=None,
            record_path=None,
            url="https://audio-samples.github.io/samples/mp3/blizzard_biased/sample-0.mp3",
			sys_prompt="You are an AI assistant with a listening charter to clearly analyze the customer enquiry.",
			user_prompt="Summarize the audio content",
			api_name="/process_audio"
        )
        print(f"Gradio API call at {datetime.now()}")
        print(f"Summarized Output : {response}")
        return response

    except Exception as ex:
        return print(f"Error calling Gradio app: {ex}")
        #pass



if __name__ == "__main__":
    main()