Skip to content

Instantly share code, notes, and snippets.

View istupakov's full-sized avatar

Ilya Stupakov istupakov

View GitHub Profile
@istupakov
istupakov / read_wav.py
Last active April 17, 2025 10:24
Read PCM wav file with pure python and numpy
import wave
import numpy as np
import numpy.typing as npt
def read_wav(filename: str) -> tuple[npt.NDArray[np.float32], int]:
"""
Read PCM wav file
Support PCM_U8, PCM_16, PCM_24 and PCM_32 formats.
@istupakov
istupakov / gigaam-onnx-export.py
Last active March 8, 2025 13:43
GigaAM CTC v2 export to onnx (with metadata for sherpa_onnx) and inference examples
import onnx
import gigaam
from gigaam.onnx_utils import VOCAB
onnx_dir = "gigaam-onnx"
model_type = "v2_ctc"
model = gigaam.load_model(
model_type,
fp16_encoder=False, # only fp32 tensors
@istupakov
istupakov / online_stft.cpp
Last active December 17, 2023 03:20
Online STFT on C++ (fftw)
#include <vector>
#include <span>
#include <complex>
#include <cmath>
#include <numbers>
#include <fftw3.h>
using std::complex;
using std::span;
@istupakov
istupakov / online_stft.py
Last active June 3, 2024 11:22
Online STFT on Python (numpy)
import numpy as np
import numpy.typing as npt
class OnlineStft:
n_freq: int
def __init__(self, n_fft: int, n_hop: int, n_channels: int):
self._hop = n_hop
self.n_freq = n_fft // 2 + 1
self._win_a = np.hamming(n_fft + 1)[:-1]
@istupakov
istupakov / WordToQTI.cs
Last active July 14, 2021 10:17
Word to QTI Converter
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Drawing.Imaging;
using System.IO;
using System.IO.Compression;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Windows.Forms;
@istupakov
istupakov / markdown.component.ts
Created June 7, 2017 16:38
Angular 4 Markdown Component with Router Navigation.
import { Component, Input, ViewChild, AfterViewInit, ElementRef } from '@angular/core';
import { Router } from '@angular/router';
import { markdown } from 'markdown';
@Component({
selector: 'markdown',
template: `<div [innerHtml]="html" #root></div>`
})
export class MarkdownComponent implements AfterViewInit {
@ViewChild('root') root: ElementRef;
@istupakov
istupakov / AutomaticDifferentiation.cs
Last active February 2, 2017 21:09
Automatic differentiation (second order) on C# with Roslyn for parsing.
using System;
using System.Linq.Expressions;
using System.Reflection;
using System.Threading.Tasks;
using Microsoft.CodeAnalysis.CSharp.Scripting;
using Microsoft.CodeAnalysis.Scripting;
namespace AutomaticDifferentiation
{
public struct DualNumber
@istupakov
istupakov / neerc2016-L.cpp
Created December 9, 2016 19:24
ACM ICPC NEERC 2016: Problem L. List of Primes
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
#include <map>
using namespace std;
pair<int, int> get_next_prime(int k)
{
for (int i = 2; i < k; i++)
@istupakov
istupakov / neerc2016-F.cpp
Created December 9, 2016 19:21
ACM ICPC NEERC 2016: Problem F. Foreign Postcards
#include <iostream>
#include <string>
#include <iomanip>
using namespace std;
int main()
{
std::string a;
getline(std::cin, a);
@istupakov
istupakov / ShuntingYardParser.cs
Last active December 19, 2024 09:26
C# realization of Shunting-yard algorithm
using System.Collections.Frozen;
using System.Text;
var text = Console.ReadLine()!;
using var reader = new StringReader(text);
var parser = new Parser();
var tokens = parser.Tokenize(reader).ToList();
Console.WriteLine(string.Join("\n", tokens));