diff --git a/demo/components/audio_test.py b/demo/components/audio_test.py new file mode 100644 index 0000000000000000000000000000000000000000..542d9514c9fd94341cf2e7150cbd078a2dfa70c5 --- /dev/null +++ b/demo/components/audio_test.py @@ -0,0 +1,48 @@ +# Copyright (c) 2020 VisualDL Authors. All Rights Reserve. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# ======================================================================= +# coding=utf-8 +from visualdl import LogWriter +import numpy as np +import wave + + +def read_audio_data(audio_path): + """ + Get audio data. + """ + CHUNK = 4096 + f = wave.open(audio_path, "rb") + rate = f.getframerate() + width = f.getsampwidth() + channel = f.getnchannels() + wavdata = [] + chunk = f.readframes(CHUNK) + + while chunk: + data = np.frombuffer(chunk, dtype='uint8') + wavdata.extend(data) + chunk = f.readframes(CHUNK) + shape = [rate, width, channel] + return shape, wavdata + + +if __name__ == '__main__': + with LogWriter(logdir="vdl_audio_0713") as writer: + audio_shape, audio_data = read_audio_data("./test.wav") + audio_data = np.array(audio_data) + writer.add_audio(tag="audio_tag", + audio_array=audio_data, + step=0, + sample_rate=audio_shape[0]) diff --git a/demo/components/test.wav b/demo/components/test.wav new file mode 100644 index 0000000000000000000000000000000000000000..a1170d8057d76ec1073a13089903e85332fe47ea Binary files /dev/null and b/demo/components/test.wav differ diff --git a/visualdl/server/data_manager.py b/visualdl/server/data_manager.py index 349b32508f35c54ee5d832ce6fa8239bb60f007a..6dcaa58fcc85bfeed07ee7f4ed62c568788d71d1 100644 --- a/visualdl/server/data_manager.py +++ b/visualdl/server/data_manager.py @@ -19,7 +19,7 @@ import random import collections DEFAULT_PLUGIN_MAXSIZE = { - "scalar": 300, + "scalar": 1000, "image": 10, "histogram": 100, "embeddings": 50000,