Skip to content

Commit

Permalink
fix unit test (#3835)
Browse files Browse the repository at this point in the history
  • Loading branch information
zxcd authored Aug 29, 2024
1 parent a9ece28 commit d9eb82a
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 18 deletions.
10 changes: 5 additions & 5 deletions tests/unit/asr/deepspeech2_model_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ def test_ds2_1(self):
num_rnn_layers=3,
rnn_size=1024,
use_gru=False,
share_rnn_weights=False, )
rnn_direction="forward", )
loss = model(self.audio, self.audio_len, self.text, self.text_len)
self.assertEqual(loss.numel(), 1)

Expand All @@ -60,7 +60,7 @@ def test_ds2_2(self):
num_rnn_layers=3,
rnn_size=1024,
use_gru=True,
share_rnn_weights=False, )
rnn_direction="forward", )
loss = model(self.audio, self.audio_len, self.text, self.text_len)
self.assertEqual(loss.numel(), 1)

Expand All @@ -72,7 +72,7 @@ def test_ds2_3(self):
num_rnn_layers=3,
rnn_size=1024,
use_gru=False,
share_rnn_weights=True, )
rnn_direction="bidirect", )
loss = model(self.audio, self.audio_len, self.text, self.text_len)
self.assertEqual(loss.numel(), 1)

Expand All @@ -84,7 +84,7 @@ def test_ds2_4(self):
num_rnn_layers=3,
rnn_size=1024,
use_gru=True,
share_rnn_weights=True, )
rnn_direction="bidirect", )
loss = model(self.audio, self.audio_len, self.text, self.text_len)
self.assertEqual(loss.numel(), 1)

Expand All @@ -96,7 +96,7 @@ def test_ds2_5(self):
num_rnn_layers=3,
rnn_size=1024,
use_gru=False,
share_rnn_weights=False, )
rnn_direction="forward", )
loss = model(self.audio, self.audio_len, self.text, self.text_len)
self.assertEqual(loss.numel(), 1)

Expand Down
24 changes: 12 additions & 12 deletions tests/unit/asr/deepspeech2_online_model_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@
import paddle
from paddle import inference

from paddlespeech.s2t.models.ds2_online import DeepSpeech2InferModelOnline
from paddlespeech.s2t.models.ds2_online import DeepSpeech2ModelOnline
from paddlespeech.s2t.models.ds2 import DeepSpeech2InferModel
from paddlespeech.s2t.models.ds2 import DeepSpeech2Model


class TestDeepSpeech2ModelOnline(unittest.TestCase):
class TestDeepSpeech2Model(unittest.TestCase):
def setUp(self):
paddle.set_device('cpu')

Expand All @@ -45,7 +45,7 @@ def setUp(self):
self.text_len = paddle.to_tensor(text_len, dtype='int64')

def test_ds2_1(self):
model = DeepSpeech2ModelOnline(
model = DeepSpeech2Model(
feat_size=self.feat_dim,
dict_size=10,
num_conv_layers=2,
Expand All @@ -58,7 +58,7 @@ def test_ds2_1(self):
self.assertEqual(loss.numel(), 1)

def test_ds2_2(self):
model = DeepSpeech2ModelOnline(
model = DeepSpeech2Model(
feat_size=self.feat_dim,
dict_size=10,
num_conv_layers=2,
Expand All @@ -71,7 +71,7 @@ def test_ds2_2(self):
self.assertEqual(loss.numel(), 1)

def test_ds2_3(self):
model = DeepSpeech2ModelOnline(
model = DeepSpeech2Model(
feat_size=self.feat_dim,
dict_size=10,
num_conv_layers=2,
Expand All @@ -84,7 +84,7 @@ def test_ds2_3(self):
self.assertEqual(loss.numel(), 1)

def test_ds2_4(self):
model = DeepSpeech2ModelOnline(
model = DeepSpeech2Model(
feat_size=self.feat_dim,
dict_size=10,
num_conv_layers=2,
Expand All @@ -97,7 +97,7 @@ def test_ds2_4(self):
self.assertEqual(loss.numel(), 1)

def test_ds2_5(self):
model = DeepSpeech2ModelOnline(
model = DeepSpeech2Model(
feat_size=self.feat_dim,
dict_size=10,
num_conv_layers=2,
Expand All @@ -110,7 +110,7 @@ def test_ds2_5(self):
self.assertEqual(loss.numel(), 1)

def test_ds2_6(self):
model = DeepSpeech2ModelOnline(
model = DeepSpeech2Model(
feat_size=self.feat_dim,
dict_size=10,
num_conv_layers=2,
Expand All @@ -125,7 +125,7 @@ def test_ds2_6(self):

def test_ds2_7(self):
use_gru = False
model = DeepSpeech2ModelOnline(
model = DeepSpeech2Model(
feat_size=self.feat_dim,
dict_size=10,
num_conv_layers=2,
Expand Down Expand Up @@ -156,7 +156,7 @@ def test_ds2_7(self):

def test_ds2_8(self):
use_gru = True
model = DeepSpeech2ModelOnline(
model = DeepSpeech2Model(
feat_size=self.feat_dim,
dict_size=10,
num_conv_layers=2,
Expand Down Expand Up @@ -191,7 +191,7 @@ def setUp(self):
export_prefix = "exp/deepspeech2_online/checkpoints/test_export"
if not os.path.exists(os.path.dirname(export_prefix)):
os.makedirs(os.path.dirname(export_prefix), mode=0o755)
infer_model = DeepSpeech2InferModelOnline(
infer_model = DeepSpeech2InferModel(
feat_size=161,
dict_size=4233,
num_conv_layers=2,
Expand Down
2 changes: 2 additions & 0 deletions tests/unit/server/offline/test_server_client.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#!/bin/bash
# bash test_server_client.sh
## require lsof to get server pid
## apt-get install -y lsof

StartService(){
# Start service
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/tts/test_data_table.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
# 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.
from paddlespeech.t2s.datasets.data_tabel import DataTable
from paddlespeech.t2s.datasets.data_table import DataTable


def test_audio_dataset():
Expand Down

0 comments on commit d9eb82a

Please sign in to comment.