mirror of
https://github.com/gradio-app/gradio.git
synced 2025-02-05 11:10:03 +08:00
added rebuild method to audio
This commit is contained in:
parent
4c74705ace
commit
24d84ba612
@ -865,6 +865,15 @@ class Audio(InputComponent):
|
||||
else:
|
||||
raise ValueError("Unknown type: " + str(self.type) + ". Please choose from: 'numpy', 'mfcc', 'file'.")
|
||||
|
||||
def rebuild(self, dir, data):
|
||||
inp = data.split(';')[1].split(',')[1]
|
||||
wav_obj = base64.b64decode(inp)
|
||||
timestamp = datetime.datetime.now()
|
||||
filename = f'input_{timestamp.strftime("%Y-%m-%d-%H-%M-%S")}.wav'
|
||||
with open("{}/{}".format(dir, filename), "wb+") as f:
|
||||
f.write(wav_obj)
|
||||
return filename
|
||||
|
||||
|
||||
class File(InputComponent):
|
||||
"""
|
||||
|
Loading…
Reference in New Issue
Block a user