Skip to content

Instantly share code, notes, and snippets.

View carlfm01's full-sized avatar

Carlos Fonseca carlfm01

  • Costa Rica
View GitHub Profile
@carlfm01
carlfm01 / split-sentences.py
Created September 5, 2019 21:18
Sentences
import spacy
from spacy import displacy
from spacy.lang.es.examples import sentences
f = open("result.txt", mode="w+", encoding="utf-8")
with open('data.txt', mode="r", encoding="utf-8") as file:
data = file.read().replace('\n', '')
nlp = spacy.load('es_core_news_sm', disable=['ner', 'textcat'])
doc = nlp(data)
@carlfm01
carlfm01 / test.cs
Created October 7, 2019 20:33
C# DeepSpeech same file test
using DeepSpeechClient;
using DeepSpeechClient.Interfaces;
using DeepSpeechClient.Models;
using NAudio.Wave;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
@carlfm01
carlfm01 / audio.py
Created October 10, 2019 02:12
Just a quick test for LPCNet inference
import librosa
import librosa.filters
import numpy as np
import tensorflow as tf
from scipy import signal
from scipy.io import wavfile
def save_wavenet_wav(wav, path, sr, inv_preemphasize, k):
# wav = inv_preemphasis(wav, k, inv_preemphasize)
wav *= 32767 / max(0.01, np.max(np.abs(wav)))
@carlfm01
carlfm01 / rrnoiseresample.c
Last active December 11, 2019 03:47
rnnoiseresample
for (size_t n = 0; n < totalFrameCnt / 160; n++) {
get_frame_f32(pWavIn, frameIn, 160);
float *input = (float *)malloc(480 * sizeof(float));
float *output = (float *)malloc(160 * sizeof(float));
//Upsample from 16KHz to 48KHz
Resample_f32(frameIn, input, 16000, 48000, 160, 1);
float prob = rnnoise_process(pRnnoise, frameOut, input);
if (isOutput) {
total_parameters = 0
for variable in tf.trainable_variables():
# shape is an array of tf.Dimension
shape = variable.get_shape()
print(shape)
variable_parameters = 1
for dim in shape:
variable_parameters *= dim.value
total_parameters += variable_parameters
print(f'TOTAL: {total_parameters}')
@carlfm01
carlfm01 / cuda_10.1_installation_on_Ubuntu_18.04
Created February 3, 2021 09:24 — forked from Mahedi-61/cuda_11.8_installation_on_Ubuntu_22.04
CUDA 10.1 Installation on Ubuntu 18.04
#!/bin/bash
## This gist contains instructions about cuda v10.1 and cudnn 7.6 installation in Ubuntu 18.04 for Tensorflow 2.1.0
### steps ####
# verify the system has a cuda-capable gpu
# download and install the nvidia cuda toolkit and cudnn
# setup environmental variables
# verify the installation
###
@carlfm01
carlfm01 / cuda_11.7_installation_on_Ubuntu_22.04
Created April 27, 2023 05:47 — forked from X-TRON404/cuda_11.7_installation_on_Ubuntu_22.04
Instructions for CUDA v11.7 and cuDNN 8.5 installation on Ubuntu 22.04 for PyTorch 1.12.1
#!/bin/bash
### steps ####
# verify the system has a cuda-capable gpu
# download and install the nvidia cuda toolkit and cudnn
# setup environmental variables
# verify the installation
###
### to verify your gpu is cuda enable check
var message = new MimeMessage();
message.From.Add(new MailboxAddress("Your Name", "your-email@yourdomain.com"));
message.To.Add(new MailboxAddress("", recipientEmail));
message.Subject = subject;
message.Body = new TextPart("html")
{
Text = body
};
import os
import time
from typing import Optional, Tuple
import torch
from PIL import Image
import onnxruntime as onnxrt
import requests
from transformers import AutoConfig, AutoModelForVision2Seq, TrOCRProcessor, VisionEncoderDecoderModel