mirror of
https://github.com/gradio-app/gradio.git
synced 2024-12-21 02:19:59 +08:00
audio flagging
This commit is contained in:
parent
7595e1e41b
commit
82d622028c
@ -11,6 +11,7 @@ import time
|
||||
import warnings
|
||||
from abc import ABC, abstractmethod
|
||||
|
||||
import base64
|
||||
import numpy as np
|
||||
import PIL.Image
|
||||
import PIL.ImageOps
|
||||
@ -397,7 +398,7 @@ class Webcam(AbstractInput):
|
||||
im = preprocessing_utils.decode_base64_to_image(data)
|
||||
timestamp = datetime.datetime.now()
|
||||
filename = f'input_{timestamp.strftime("%Y-%m-%d-%H-%M-%S")}.png'
|
||||
im.save(f'{dir}/{filename}', 'PNG')
|
||||
im.save('{}/{}'.format(dir, filename), 'PNG')
|
||||
return filename
|
||||
|
||||
|
||||
@ -436,6 +437,15 @@ class Microphone(AbstractInput):
|
||||
_, signal = scipy.io.wavfile.read(file_obj.name)
|
||||
return signal
|
||||
|
||||
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
|
||||
|
||||
|
||||
# Automatically adds all shortcut implementations in AbstractInput into a dictionary.
|
||||
shortcuts = {}
|
||||
|
@ -4,7 +4,6 @@ interface using the input and output types.
|
||||
"""
|
||||
|
||||
import tempfile
|
||||
import traceback
|
||||
import webbrowser
|
||||
|
||||
import gradio.inputs
|
||||
@ -217,7 +216,8 @@ class Interface:
|
||||
def launch(self, inline=None, inbrowser=None, share=False, debug=False):
|
||||
"""
|
||||
Parameters
|
||||
share (bool): whether to create a publicly shareable link from your computer for the interface.
|
||||
share (bool): whether to create a publicly shareable link from
|
||||
your computer for the interface.
|
||||
"""
|
||||
|
||||
output_directory = tempfile.mkdtemp()
|
||||
|
Loading…
Reference in New Issue
Block a user