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:
@@ -5,3 +5,7 @@ This directory contains APIs for [Object Pascal](https://en.wikipedia.org/wiki/O
|
||||
Please see
|
||||
https://github.com/k2-fsa/sherpa-onnx/tree/master/pascal-api-examples
|
||||
for usages.
|
||||
|
||||
[portaudio.pas](./portaudio.pas)
|
||||
is copied from
|
||||
https://github.com/UltraStar-Deluxe/USDX/blob/master/src/lib/portaudio/portaudio.pas
|
||||
|
||||
1161
sherpa-onnx/pascal-api/portaudio.pas
Normal file
1161
sherpa-onnx/pascal-api/portaudio.pas
Normal file
File diff suppressed because it is too large
Load Diff
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user