Skip to content

Instantly share code, notes, and snippets.

View DevloperHS's full-sized avatar

Purnendu Shukla(Harsh) DevloperHS

View GitHub Profile
@DevloperHS
DevloperHS / answers.py
Last active November 15, 2021 07:47
Pokémon Optimize
# printing out results - > Best 6 pokemons
for i in range(206):
if Pokemon[i].value() == 1:
print(names[i])
import csv
import json
import logging
import multiprocessing
import os
import tarfile
from multiprocessing.pool import ThreadPool
from pathlib import Path
from typing import List
import argparse
import csv
import json
import logging
import multiprocessing
import os
import tarfile
from multiprocessing.pool import ThreadPool
from pathlib import Path
from typing import List
parser = argparse.ArgumentParser(description='Downloads and processes Mozilla Common Voice dataset.')
parser.add_argument("--data_root", default='./', type=str, help="Directory to store the dataset.")
parser.add_argument('--manifest_dir', default='manifest_dir/', type=str, help='Output directory for manifests')
parser.add_argument("--num_workers", default=multiprocessing.cpu_count(), type=int, help="Workers to process dataset.")
parser.add_argument('--sample_rate', default=16000, type=int, help='Sample rate')
parser.add_argument('--files_to_process', nargs='+', default=['test.tsv', 'dev.tsv', 'train.tsv'],
type=str, help='list of *.csv file names to process')
parser.add_argument('--version', default='cv-corpus-7.0-2021-07-21',
type=str, help='Version of the dataset (obtainable via https://commonvoice.mozilla.org/en/datasets')
parser.add_argument('--language', default='hi',
# https://mozilla-common-voice-datasets.s3.dualstack.us-west-2.amazonaws.com/cv-corpus-7.0-2021-07-21/cv-corpus-7.0-2021-07-21-en.tar.gz
COMMON_VOICE_URL = f"https://voice-prod-bundler-ee1969a6ce8178826482b88e843c335139bd3fb4.s3.amazonaws.com/" \
"{}/{}-{}.tar.gz".format(args.version, args.version, args.language)
# https://mozilla-common-voice-datasets.s3.dualstack.us-west-2.amazonaws.com/cv-corpus-7.0-2021-07-21/cv-corpus-7.0-2021-07-21-en.tar.gz
COMMON_VOICE_URL = f"https://voice-prod-bundler-ee1969a6ce8178826482b88e843c335139bd3fb4.s3.amazonaws.com/" \
"{}/{}-{}.tar.gz".format(args.version, args.version, args.language)
def process_files(csv_file, data_root, num_workers):
""" Read *.csv file description, convert mp3 to wav, process text.
Save results to data_root.
Args:
csv_file: str, path to *.csv file with data description, usually start from 'cv-'
data_root: str, path to dir to save results; wav/ dir will be created
"""
wav_dir = os.path.join(data_root, 'wav/')
os.makedirs(wav_dir, exist_ok=True)
audio_clips_path = os.path.dirname(csv_file) + '/clips/'
def create_manifest(
data: List[tuple],
output_name: str,
manifest_path: str):
output_file = Path(manifest_path) / output_name
output_file.parent.mkdir(exist_ok=True, parents=True)
def main():
data_root = args.data_root
os.makedirs(data_root, exist_ok=True)
target_unpacked_dir = os.path.join(data_root, "CV_unpacked")
if os.path.exists(target_unpacked_dir):
logging.info('Find existing folder {}'.format(target_unpacked_dir))
else:
logging.info("Could not find Common Voice, Downloading corpus...")
@DevloperHS
DevloperHS / index.html
Created July 15, 2022 10:50
UI file for interacting with smart contract
<!DOCTYPE html>
<html lang="en">
<head>
<!--Adding Meta Data For Browser-->
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="main.css">
<title>Mood Dairy</title>