You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mxnet.apache.org by GitBox <gi...@apache.org> on 2019/05/09 03:25:44 UTC

[GitHub] [incubator-mxnet] vandanavk commented on a change in pull request #13735: update wavenet codes

vandanavk commented on a change in pull request #13735: update wavenet codes
URL: https://github.com/apache/incubator-mxnet/pull/13735#discussion_r282326296
 
 

 ##########
 File path: example/gluon/wavenet/data_loader.py
 ##########
 @@ -0,0 +1,55 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you 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
+"""
+Description : Set Dataset module for Wavenet
+"""
+import os
+import numpy as np
+from mxnet import nd
+from scipy.io import wavfile
+from utils import encode_mu_law
+# pylint: disable=invalid-name, too-many-arguments
+
+def load_wav(file_nm):
+    """
+    Description : load wav file
+    """
+    fs, data = wavfile.read(os.getcwd()+'/dataset/'+file_nm)
+    return  fs, data
+
+def data_generation(data, seq_size, mu, ctx):
+    """
+    Description : data generation to loading data
+    """
+    div = max(data.max(), abs(data.min()))
+    data = data/div
+    while True:
+        start = np.random.randint(0, data.shape[0]-seq_size)
+        ys = data[start:start+seq_size]
+        ys = encode_mu_law(ys, mu)
+        yield nd.array(ys[:seq_size], ctx=ctx)
+
+def data_generation_sample(data, seq_size, mu, ctx):
+    """
+    Description : sample data generation to loading data
+    """
+    div = max(data.max(), abs(data.min()))
+    data = data/div
 
 Review comment:
   can div be 0 here?

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services