Skip to content

Commit

Permalink
audio flagging
Browse files Browse the repository at this point in the history
  • Loading branch information
aliabd committed Aug 3, 2020
1 parent 7595e1e commit 82d6220
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
12 changes: 11 additions & 1 deletion gradio/inputs.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import warnings
from abc import ABC, abstractmethod

import base64
import numpy as np
import PIL.Image
import PIL.ImageOps
Expand Down Expand Up @@ -397,7 +398,7 @@ def rebuild(self, dir, data):
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


Expand Down Expand Up @@ -436,6 +437,15 @@ def preprocess(self, inp):
_, 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 = {}
Expand Down
4 changes: 2 additions & 2 deletions gradio/interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
"""

import tempfile
import traceback
import webbrowser

import gradio.inputs
Expand Down Expand Up @@ -217,7 +216,8 @@ def close(self):
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()
Expand Down

0 comments on commit 82d6220

Please sign in to comment.