提交 32ef4f9e 编写于 作者: N Nicky Chan 提交者: daminglu

Add audio integration demo in scratch log to demonstrate read audio wave data and API usage (#363)

上级 cfa6b029
文件已添加
...@@ -3,6 +3,7 @@ import os ...@@ -3,6 +3,7 @@ import os
import random import random
import numpy as np import numpy as np
import wave
from PIL import Image from PIL import Image
from visualdl import ROOT, LogWriter from visualdl import ROOT, LogWriter
from visualdl.server.log import logger as log from visualdl.server.log import logger as log
...@@ -91,6 +92,32 @@ with logw.mode("train") as logger: ...@@ -91,6 +92,32 @@ with logw.mode("train") as logger:
image0.finish_sampling() image0.finish_sampling()
#create audio
with logw.mode("train") as logger:
audio = logger.audio("scratch/audio_1", 4) # randomly sample 4 audio one pass
CHUNK = 4096
f = wave.open('./testing.wav', "rb")
wavdata = []
chunk = f.readframes(CHUNK)
while chunk:
data = np.fromstring(chunk, dtype='uint8')
wavdata.extend(data)
chunk = f.readframes(CHUNK)
for pass_ in range(4):
audio.start_sampling()
for sample in range(10):
idx = audio.is_sample_taken()
if idx >= 0:
audio.set_sample(idx, 8000, wavdata)
audio.finish_sampling()
def download_graph_image(): def download_graph_image():
''' '''
This is a scratch demo, it do not generate a ONNX proto, but just download an image This is a scratch demo, it do not generate a ONNX proto, but just download an image
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册