gossp

package module
v0.0.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 4, 2014 License: MIT Imports: 2 Imported by: 0

README

GOSSP Build Status


GOSSP is a Speech Signal Processing library for the Go language, which includes time-frequency analysis, fundamental frequency estimation, spectral envelope estimation and waveform generation filters, etc.

Packages

  • cwt - Continuous Wavelet Tranform (CWT) and inverse CWT (in develop).
  • dct - Discrete Cosine Transform (DCT) and Inverse DCT.
  • dtw - Dynamic Time Warping (DTW)
  • excite - Excitation generation from fundamental frequency.
  • f0 - Fundamental frequency (f0) estimatnion.
  • io - Input/Output (in develop).
  • mgcep - Mel-generalized cepstrum analysis for spectral envelope estimation.
  • special - Special functions analogy to scipy in python.
  • stft - Short-Time Fourier Transform (STFT) and Inverse STFT.
  • vocoder - Speech waveform generation filters.
  • window - Window functions.
  • z - Z-transform to analyze digital filters.

Install

 go get github.com/r9y9/gossp
Install SPTK

To use SPTK with GOSSP, you need to install the modified version of SPTK as follows:

 git clone https://github.com/r9y9/SPTK.git && cd SPTK
 ./waf configure && ./waf
 sudo ./waf install

Getting Started

Short-Time Fourier Transform

package main

import (
	"flag"
	"fmt"
	"github.com/r9y9/gossp"
	"github.com/r9y9/gossp/io"
	"github.com/r9y9/gossp/stft"
	"github.com/r9y9/gossp/window"
	"log"
	"math"
)

func main() {
	filename := flag.String("i", "input.wav", "Input filename")
	flag.Parse()

	w, werr := io.ReadWav(*filename)
	if werr != nil {
		log.Fatal(werr)
	}
	data := w.GetMonoData()

	s := &stft.STFT{
		FrameShift: int(float64(w.SampleRate) / 100.0), // 0.01 sec,
		FrameLen:   2048,
		Window:     window.CreateHanning(2048),
	}

	spectrogram, _ := gossp.SplitSpectrogram(s.STFT(data))
	PrintMatrixAsGnuplotFormat(spectrogram)
}

func PrintMatrixAsGnuplotFormat(matrix [][]float64) {
	fmt.Println("#", len(matrix[0]), len(matrix)/2)
	for i, vec := range matrix {
		for j, val := range vec[:1024] {
			fmt.Println(i, j, math.Log(val))
		}
		fmt.Println("")
	}
}
Waveform Reconstruction using Inverse Short-Time Fourier Transform
package main

import (
	"flag"
	"fmt"
	"github.com/r9y9/gossp/io"
	"github.com/r9y9/gossp/stft"
	"github.com/r9y9/gossp/window"
	"log"
)

func main() {
	filename := flag.String("i", "input.wav", "Input filename")
	flag.Parse()

	w, werr := io.ReadWav(*filename)
	if werr != nil {
		log.Fatal(werr)
	}
	data := w.GetMonoData()

	s := &stft.STFT{
		FrameShift: int(float64(w.SampleRate) / 100.0), // 0.01 sec,
		FrameLen:   2048,
		Window:     window.CreateHanning(2048),
	}

	spectrogram := s.STFT(data)

	// do something on spectrogram

	reconstructed := s.ISTFT(spectrogram)

	for i := range data {
		// expect to be same
		fmt.Println(data[i], reconstructed[i])
	}
}

Fun with speech signal processing!

Third Party Libraries

LICENSE

MIT

Documentation

Overview

Package gossp provides support for speech signal processing.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Angle

func Angle(z complex128) float64

Angle returns angle of complex number in radian.

func DivideFrames

func DivideFrames(input []float64, frameLen, frameShift int) [][]float64

DivideFrames returns overlapping divided frames.

func HistC

func HistC(x, edges []float64) []int

Matlab

func Hz2Mel

func Hz2Mel(freq float64) float64

Hz2Mel converts frequency in hz to mel.

func Interp1

func Interp1(x, y, xi []float64) []float64

Matlab

func Mel2Hz

func Mel2Hz(mel float64) float64

Mel2Hz converts frequency in mel to hz.

func ReconstructSpectrogram

func ReconstructSpectrogram(amplitudeSpectrogram,
	phaseSpectrogram [][]float64) [][]complex128

ReconstructSpectrogram returns complex spectrogram from amplitude phase spectrogram.

func ReconstructSpectrum

func ReconstructSpectrum(amp, phase []float64) []complex128

ReconstructSpectrum returns complex spectrum from amplitude and phase spectrum. angle(X(k)) and |X(k)| -> X(k)

func SplitSpectrogram

func SplitSpectrogram(spectrogram [][]complex128) ([][]float64, [][]float64)

SplitSpectrogram returns SpilitSpectrum for each time frame.

func SplitSpectrum

func SplitSpectrum(spec []complex128) ([]float64, []float64)

SplitSpectrum splits complex spectrum X(k) to amplitude |X(k)| and angle(X(k))

func Symmetrize

func Symmetrize(x []float64) []float64

Symmetrize returns symmetrized vector given a input vector.

func ToReal

func ToReal(x []complex128) []float64

ToReal performs a real sequence from a complex sequence.

func UnWrap

func UnWrap(phase []float64) []float64

UnWrap returns unwraped phase given a phase spectrum.

Types

This section is empty.

Directories

Path Synopsis
3rdparty
mcepalpha
Package mcepalpha provides support for determination of all-pass constant for mel-cepstrum analysis.
Package mcepalpha provides support for determination of all-pass constant for mel-cepstrum analysis.
sptk
Package sptk provides Go interface to SPTK (Speech Signal Processing Toolkit), which is originally written in C.
Package sptk provides Go interface to SPTK (Speech Signal Processing Toolkit), which is originally written in C.
Package dct provides support for Discrete Cosine Transform (DCT).
Package dct provides support for Discrete Cosine Transform (DCT).
Package dtw provides support for Dynamic Time Warping (DTW) to align two time-series.
Package dtw provides support for Dynamic Time Warping (DTW) to align two time-series.
Package excite provides support for excitation generation from fundamental frequency.
Package excite provides support for excitation generation from fundamental frequency.
Package f0 provides support for fundamental frequency (f0) estimatnion.
Package f0 provides support for fundamental frequency (f0) estimatnion.
Package io privides I/O for speech signal processing.
Package io privides I/O for speech signal processing.
Package mgcep provides support for Mel-Generalized Cepstrum Analysis.
Package mgcep provides support for Mel-Generalized Cepstrum Analysis.
Package special provides special functions.
Package special provides special functions.
Package stft provides support for Short-Time Fourier Transform (STFT) Analysis.
Package stft provides support for Short-Time Fourier Transform (STFT) Analysis.
Package vocoder provides support for vocoding.
Package vocoder provides support for vocoding.
Package window provides window functions.
Package window provides window functions.
z
Package z provides support for Z transform to analyze digital filters.
Package z provides support for Z transform to analyze digital filters.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL