"""Choosing hardware"""
    device = 'cuda' if torch.cuda.is_available() else 'cpu'
    if device == "cuda":
        print(
            "Using GPU. Setting default tensor type to torch.cuda.FloatTensor")
        torch.set_default_tensor_type("torch.cuda.FloatTensor")
    else:
        print("Using CPU. Setting default tensor type to torch.FloatTensor")
        torch.set_default_tensor_type("torch.FloatTensor")
    """Converting model to specified hardware and format"""
    acoustic_cfg_json = json.load(
        open(args.acoustic_model.replace(".torch", ".json"), "r"))
    acoustic_cfg = AcousticConfig.from_json(acoustic_cfg_json)

    acoustic_model = CNN(acoustic_cfg)
    acoustic_model.float().to(device)
    try:
        acoustic_model.load_state_dict(torch.load(args.acoustic_model))
    except:
        print(
            "Failed to load model from {} without device mapping. Trying to load with mapping to {}"
            .format(args.acoustic_model, device))
        acoustic_model.load_state_dict(
            torch.load(args.acoustic_model, map_location=device))
    linguistic_cfg_json = json.load(
        open(args.linguistic_model.replace(".torch", ".json"), "r"))
    linguistic_cfg = LinguisticConfig.from_json(linguistic_cfg_json)

    linguistic_model = AttentionModel(linguistic_cfg)
    linguistic_model.float().to(device)
    write(TMP_FILENAME, SAMPLE_RATE, myrecording)  # Save as WAV file

    from deepspeech_generator import speech_to_text
    transcription = speech_to_text(join(args.deepspeech, "output_graph.pbmm"),
                                   join(args.deepspeech, "alphabet.txt"),
                                   join(args.deepspeech, "lm.binary"),
                                   join(args.deepspeech, "trie"), TMP_FILENAME)
    print(transcription)
    """Converting model to specified hardware and format"""
    acoustic_cfg_json = json.load(
        open(args.acoustic_model.replace(".torch", ".json"), "r"))
    acoustic_cfg = AcousticSpectrogramConfig.from_json(acoustic_cfg_json)

    acoustic_model = CNN(acoustic_cfg)
    acoustic_model.float().to("cpu")

    try:
        acoustic_model.load_state_dict(torch.load(args.acoustic_model))
    except:
        print(
            "Failed to load model from {} without device mapping. Trying to load with mapping to {}"
            .format(args.acoustic_model, "cpu"))
        acoustic_model.load_state_dict(
            torch.load(args.acoustic_model, map_location="cpu"))

    acoustic_model.eval()

    linguistic_cfg_json = json.load(
        open(args.linguistic_model.replace(".torch", ".json"), "r"))
    linguistic_cfg = LinguisticConfig.from_json(linguistic_cfg_json)