Skip to content

Commit

Permalink
add ltu-v2 api call demo
Browse files Browse the repository at this point in the history
  • Loading branch information
Yuan Gong committed Sep 6, 2023
1 parent 03675aa commit 7c49f8b
Showing 1 changed file with 1 addition and 52 deletions.
53 changes: 1 addition & 52 deletions ltu2_api_demo.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,58 +3,7 @@
# @Author : Yuan Gong
# @Affiliation : Massachusetts Institute of Technology
# @Email : yuangong@mit.edu
# @File : api_demo.py

# method 1

# import json
# import gradio as gr
# import requests
# import os
#
# def is_file_larger_than_30mb(file_path):
# try:
# file_size = os.path.getsize(file_path)
# return file_size > (30 * 1024 * 1024)
# except FileNotFoundError:
# return False
# except PermissionError:
# return False
# except Exception as e:
# return False
#
# def upload_audio(audio_path):
# try:
# size = is_file_larger_than_30mb(audio_path)
# if size == True:
# return 'size'
# with open(audio_path, 'rb') as audio_file:
# response = requests.post('http://sls-titan-6.csail.mit.edu:8080/upload/', files={'audio_file': audio_file})
# if response.status_code == 200:
# return response.json()["path"]
# except:
# return None
#
# def predict(audio_path, question):
# upload_statues = upload_audio(audio_path)
# if upload_statues == None:
# return 'Please upload an audio file.'
# if upload_statues == 'size':
# return 'This demo does not support audio file size larger than 30MB.'
# if question == '':
# return 'Please ask a question.'
# print(audio_path, question)
# response = requests.put('http://sls-titan-6.csail.mit.edu:8080/items/0', json={
# 'audio_path': audio_path, 'question': question
# })
# answer = json.loads(response.content)
# ans_str = answer['output']
# return ans_str
#
# ans = predict('./sample_audio.wav', 'What did you hear?')
# print(ans)

# # method 2
# @File : ltu2_api_demo.py

from gradio_client import Client
import time
Expand Down

0 comments on commit 7c49f8b

Please sign in to comment.