Object pascal examples for recording and playing audio with portaudio. (#1271)

The recording example can be used for speech recognition while the playing example can be used for text to speech.

The portaudio wrapper for object pascal is copied from
https://github.com/UltraStar-Deluxe/USDX/blob/master/src/lib/portaudio/portaudio.pas
This commit is contained in:
Fangjun Kuang
2024-08-18 19:51:08 +08:00
committed by GitHub
parent f93f0ca94d
commit e34a1a2aa3
9 changed files with 1562 additions and 2 deletions

View File

@@ -10,6 +10,8 @@ unit sherpa_onnx;
(* {$LongStrings ON} *)
interface
uses
ctypes;
type
TSherpaOnnxWave = record
@@ -260,7 +262,8 @@ type
public
constructor Create(Capacity: Integer);
destructor Destroy; override;
procedure Push(Samples: array of Single);
procedure Push(Samples: array of Single); overload;
procedure Push(Samples: pcfloat; N: Integer); overload;
function Get(StartIndex: Integer; N: Integer): TSherpaOnnxSamplesArray;
procedure Pop(N: Integer);
procedure Reset;
@@ -305,7 +308,6 @@ type
implementation
uses
ctypes,
fpjson,
{ See
- https://wiki.freepascal.org/fcl-json
@@ -1323,6 +1325,11 @@ begin
SherpaOnnxCircularBufferPush(Self.Handle, pcfloat(Samples), Length(Samples));
end;
procedure TSherpaOnnxCircularBuffer.Push(Samples: pcfloat; N: Integer);
begin
SherpaOnnxCircularBufferPush(Self.Handle, Samples, N);
end;
function TSherpaOnnxCircularBuffer.Get(StartIndex: Integer; N: Integer): TSherpaOnnxSamplesArray;
var
P: pcfloat;