Beispiel #1
0
parser.add_argument("--nfx",
                    default=False,
                    action="store_true",
                    help="Choose numpy features extractor")

parser.add_argument("--device",
                    type=int,
                    default=0,
                    help="Device's id to run test on")

args = parser.parse_args()

tf.config.optimizer.set_experimental_options(
    {"auto_mixed_precision": args.mxp})

setup_devices([args.device])

from sasegan.runners.tester import SeganTester
from sasegan.datasets.test_dataset import SeganTestDataset
from tensorflow_asr.configs.config import Config
from sasegan.models.sasegan import Generator
from sasegan.featurizers.speech_featurizer import NumpySpeechFeaturizer, TFSpeechFeaturizer

config = Config(args.config)

speech_featurizer = NumpySpeechFeaturizer(config.speech_config) if args.nfx \
    else TFSpeechFeaturizer(config.speech_config)

tf.random.set_seed(0)
assert args.saved
parser.add_argument("--subwords",
                    type=str,
                    default=None,
                    help="Path to file that stores generated subwords")

parser.add_argument("--output_name",
                    type=str,
                    default="test",
                    help="Result filename name prefix")

args = parser.parse_args()

tf.config.optimizer.set_experimental_options(
    {"auto_mixed_precision": args.mxp})

setup_devices([args.device], cpu=args.cpu)

from tensorflow_asr.configs.config import Config
from tensorflow_asr.datasets.asr_dataset import ASRTFRecordDataset, ASRSliceDataset
from tensorflow_asr.featurizers.speech_featurizers import TFSpeechFeaturizer
from tensorflow_asr.featurizers.text_featurizers import SubwordFeaturizer
from tensorflow_asr.runners.base_runners import BaseTester
from tensorflow_asr.models.conformer import Conformer

config = Config(args.config, learning=True)
speech_featurizer = TFSpeechFeaturizer(config.speech_config)

if args.subwords and os.path.exists(args.subwords):
    print("Loading subwords ...")
    text_featurizer = SubwordFeaturizer.load_from_file(config.decoder_config,
                                                       args.subwords)
Beispiel #3
0
import torch.nn as nn
import soundfile as sf
import torch.nn.functional as F
from tamil_tech.torch.utils import *
from tamil_tech.torch.models import *

import numpy as np
import tensorflow as tf

from tensorflow_asr.utils import setup_environment, setup_devices

setup_environment()

tf.config.optimizer.set_experimental_options({"auto_mixed_precision": False})

setup_devices([0], cpu=False)

from tensorflow_asr.configs.config import Config
from tensorflow_asr.featurizers.speech_featurizers import TFSpeechFeaturizer
from tensorflow_asr.featurizers.text_featurizers import CharFeaturizer, SubwordFeaturizer
from tensorflow_asr.models.conformer import Conformer

class ConformerTamilASR(object):
    """
    Conformer S based ASR model
    """
    def __init__(self, path='ConformerS.h5'):
        # fetch and load the config of the model
        config = Config('tamil_tech/configs/conformer_new_config.yml', learning=True)

        # load speech and text featurizers