text stringlengths 14 100k | source stringclasses 1
value | repo stringclasses 810
values | language stringclasses 13
values |
|---|---|---|---|
<|fim_suffix|>anguageName( const char* code );
int COMLIGHTCALL getLanguageId( const char* lang );
}<|fim_prefix|>#pragma once
#include "../../ComLightLib/comLightCommon.h"
<|fim_middle|>namespace Whisper
{
int lookupLanguageId( const char* code );
int lookupLanguageId( uint32_t key );
const char* lookupL<|endof... | fim | Const-me/Whisper | c |
<|fim_prefix|>#include "stdafx.h"
#include "MelInputTensor.h"
#include "../D3D/MappedResource.h"
#include "../D3D/createBuffer.h"
#include <mfapi.h> // MFCopyIma<|fim_suffix|> portion of whisper_encode() function
const size_t ne0 = encParams.n_ctx * 2;
const size_t ne1 = encParams.n_mels;
const size_t totalElts = ne... | fim | Const-me/Whisper | cpp |
<|fim_suffix|>e() const
{
return setHigh_size( (size_t)capacity * 4 );
}
};
}<|fim_prefix|>#pragma once
#include "../ML/TensorEx.h"
#include "sEncodeParams.h"
#include "iSpectrogram.h"
namespace DirectCompute
{
// Input tensor in VRAM, in a dynamic FP32 buffer
class MelInputTensor : public TensorEx
{
u<|f... | fim | Const-me/Whisper | c |
<|fim_prefix|>#include "stdafx.h"
#include "MelStreamer.h"
#include "../Utils/parallelFor.h"
using namespace Whisper;
MelStreamer::MelStreamer( const Filters& filters, ProfileCollection& prof, const iAudioReader* iar ) :
reader( iar ),
melContext( filters ),
profiler( prof )
{ }
void MelStreamer::dropOldChunks( si... | fim | Const-me/Whisper | cpp |
<|fim_suffix|> than the argument,
// remove ( off - streamStartOffset ) chunks from the start of all 3 queues, and advance streamStartOffset to the `off` argument
void dropOldChunks( size_t off );
// Ensure PCM queues have enough chunks to generate specified count of MEL chunks
// At the end of the stream, the... | fim | Const-me/Whisper | c |
<|fim_prefix|>#include <stdafx.h>
#include "ModelBuffers.h"
#include "../ML/mlUtils.h"
namespace
{
using namespace DirectCompute;
HRESULT clone( Tensor& rdi, const Tensor& rsi )
{
CComPtr<ID3D11ShaderResourceView> srv;
CHECK( cloneResourceView( rsi, &srv ) );
rdi = rsi;
rdi.setGpuViews( srv );
return S_... | fim | Const-me/Whisper | cpp |
#include "stdafx.h"
#include "ModelLoader.h"
#if BUILD_BOTH_VERSIONS
namespace DirectCompute
{
static ModelBuffers s_model;
const ModelBuffers& gpuModel = s_model;
}
using namespace DirectCompute;
ModelLoader::ModelLoader( int encoderLayers, int decoderLayers ) :
model( s_model )
{
if( encoderLayers <= 0 || dec... | fim | Const-me/Whisper | cpp |
<|fim_prefix|>#pragma once
#include "../ML/Tensor.h"
#include <vector>
namespace DirectCompute
{
// A pair of tensors containing weights and biases; apparently, both tensors are of the same shape.
struct TensorPair
{
Tensor w, b;
__m128i getMemoryUse() const;
};
// A set of tensors for one en<|fim_suffix|> ... | fim | Const-me/Whisper | c |
<|fim_prefix|>#include "stdafx.h"
#include "ModelImpl.h"
#include "ContextImpl.h"
#include <intrin.h>
#include "../Utils/ReadStream.h"
#include "../modelFactory.h"
using namespace Whisper;
void ModelImpl::FinalRelease()
{
device.destroy();
}
HRESULT COMLIGHTCALL ModelImpl::createContext( iContext** pp )
{
auto ts ... | fim | Const-me/Whisper | cpp |
<|fim_prefix|>#pragma once
#include "../API/iContext.cl.h"
#include "../ComLightLib/comLightServer.h"
#include "WhisperModel.h"
#include "../ComLightLib/streams.h"
#include "../ML/Device.h"
namespace Whisper
{
using ComLight::iReadStream;
class ModelImpl : public ComLight::ObjectRoot<iModel>
{
DirectCompute::Dev... | fim | Const-me/Whisper | c |
<|fim_prefix|>#pragma once
#include "ModelBuffers.h"
#include <map>
namespace DirectCompute
{
struct ModelLoader
{
ModelLoader( int encoderLayers, int decoderLayers );
void add( const ggml_tensor* ggml, Tensor& gpu );
void add( const ggml_tensor* w, const ggml_tensor* b, TensorPair& gpu )
{
add<|fim_suf... | fim | Const-me/Whisper | c |
<|fim_suffix|>iteBinaryFile( LR"(C:\Temp\2remove\ML\mel-my.bin)", data.data(), data.size() * 4 );
const float* const pcmStereo = buffer->getPcmStereo();
if( nullptr != pcmStereo )
{
try
{
stereo.resize( countSamples );
}
catch( const std::bad_alloc& )
{
return E_OUTOFMEMORY;
}
memcpy( stereo.data... | fim | Const-me/Whisper | cpp |
<|fim_suffix|> size_t getLength() const noexcept override final
{
return length;
}
HRESULT pcmToMel( const iAudioBuffer* buffer, const Filters& filters, int threads = 1 );
size_t memoryUsage() const
{
return data.size() * 4;
}
};
// average the fabs of the signal
void computeSignalEnergy( std::v... | fim | Const-me/Whisper | c |
<|fim_suffix|> object.
// Instead we only decrement the ref.counter, but do not delete the object even when the counter reaches zero.
return RefCounter::implRelease();
}
};
}<|fim_prefix|>#pragma once
#include "../API/iTranscribeResult.cl.h"
#include "../ComLightLib/comLightServer.h"
namespace Whisper
{
clas... | fim | Const-me/Whisper | c |
<|fim_prefix|>#include "stdafx.h"
#include "Vocabulary.h"
#include "loaderUtils.h"
#include <regex>
using ComLight::iReadStream;
using namespace Whisper;
Vocabulary::Vocabulary() :
idFromToken( 17u, 0.75f, 0.25f, 1.5f, 1024 )
{ }
void Vocabu<|fim_suffix|>ens that form the words:
tokens.clear();
for( const auto& wo... | fim | Const-me/Whisper | cpp |
<|fim_prefix|>#pragma once
#include "../../ComLightLib/streams.h"
#include "../API/SpecialTokens.h"
#include "../Utils/MurmurHash3.h"
namespace Whisper
{
class Vocabulary
{
std::vector<const char*> tokens;
std::vector<char> stringData;
using THashMap = CAtlMap<const char*, int, StringPtrTraits>;
THashMap idF... | fim | Const-me/Whisper | c |
<|fim_suffix|> Tensor Qcur = mulMat( layer.attnQuery.w, cur );
if( 0 == il ) Tracing::tensor( "dec-Qcur-0", Qcur );
const float scaling = computeScaling( (int)ldp.n_state, (int)ldp.n_head );
addRepeatScale( Qcur, layer.attnQuery.b, scaling );
if( 0 == il ) Tracing::tensor( "dec-Qcur-1", Qcur );
// note: no b... | fim | Const-me/Whisper | cpp |
<|fim_prefix|>#pragma once
#include "../ML/MlContext.h"
#include "MelInputTensor.h"
#include "KeyValueBuffers.h"
#include "sEncodeParams.h"
#include "DecoderInputBuffers.h"
#include "DecoderResultBuffer.h"
#include "../ML/TensorsArena.h"
#include "iSpectrogram.h"
#include "../Hybrid/HybridContext.h"
#include <memory>
#... | fim | Const-me/Whisper | c |
<|fim_prefix|>#include "stdafx.h"
#include "WhisperModel.h"
#include "loaderUtils.h"
#include "../D3D/createBuffer.h"
#include <atlcoll.h>
#include <atlstr.h>
#include "../Utils/GpuProfilerSimple.h"
#include "../Utils/CpuProfiler.h"
#include "../CPU/HybridLoader.h"
#include "../ML/Reshaper.h"
using namespace Whisper;
u... | fim | Const-me/Whisper | cpp |
<|fim_suffix|>red on GPU
__m128i getLoadTimes() const
{
static_assert( offsetof( WhisperModel, loadTimeCpu ) + 8 == offsetof( WhisperModel, loadTimeGpu ) );
return _mm_loadu_si128( ( const __m128i* )( &loadTimeCpu ) );
}
__m128i getMemoryUse() const;
private:
uint64_t loadTimeCpu = 0;
uint64_t load... | fim | Const-me/Whisper | c |
<|fim_suffix|>SPER_N_MEL
constexpr uint32_t N_MEL = 80;
}<|fim_prefix|>#pragma once
#include <stdint.h>
namespace Whisper
{
// WHISPER_SAMPLE_RATE, 16 kHz
con<|fim_middle|>stexpr uint32_t SAMPLE_RATE = 16000;
// WHISPER_N_FFT, 25 milliseconds
constexpr uint32_t FFT_SIZE = 400;
// WHISPER_HOP_LENGTH, 10 milliseco... | fim | Const-me/Whisper | c |
<|fim_prefix|>#pragma once
#include "audioConstants.h"
namespace Whisper
{
struct alignas( 8 ) StereoSample
{
float left, right;
};
__interface iSpectrogram
{
// Make a buffer with length * N_MEL floats, starting at the specified offset
// An implementation of this interface may visualize the spectrogram, ... | fim | Const-me/Whisper | c |
<|fim_prefix|>#pragma once
#include "../../ComLightLib/streams.h"
namespace Whisper
{
inline HRESULT readBytes( ComLight::iReadStream* stm, void* rdi, size_t cb )
{
if( cb > INT_MAX )
return DISP_E_OVERFLOW;
if<|fim_suffix|>t::iReadStream* stm, T& dest )
{
return readBytes( stm, &dest, sizeof( T ) );
}
}<... | fim | Const-me/Whisper | c |
<|fim_suffix|> / 2; j++ )
// fftOut[ j ] += fftOut[ FFT_SIZE - j ];
for( size_t j = 1; j < 4; j++ )
fftOut[ j ] += fftOut[ FFT_SIZE - j ];
for( size_t j = 4; j < FFT_SIZE / 2; j += 4 )
{
__m128 curr = _mm_loadu_ps( fftOut + j );
// Too bad _mm_loadr_ps requires alignment
__m128 high = _mm_loadu_ps( fftOut ... | fim | Const-me/Whisper | cpp |
#pragma once
#include "audioConstants.h"
#include "WhisperModel.h"
#include <memory>
namespace Whisper
{
class HanningWindow
{
std::array<float, FFT_SIZE> hann;
public:
HanningWindow();
float operator[]( size_t i ) const
{
return hann[ i ];
}
};
extern const HanningWindow s_hanning;
class Spectro... | fim | Const-me/Whisper | c |
<|fim_suffix|>ad;
uint32_t n_audio_ctx, n_text_state, n_text_layer, n_text_ctx;
};
struct sDecodeParams
{
uint32_t n_state, n_head;
uint32_t n_ctx, n_past, M;
uint32_t n_text_layer;
uint32_t n_vocab;
};
}<|fim_prefix|>#pragma once
#include <stdint.h>
namesp<|fim_middle|>ace DirectCompute
{
struct sEnco... | fim | Const-me/Whisper | c |
<|fim_suffix|>dio_layer = 4;
int n_text_ctx = 448;
int n_text_state = 384;
int n_text_head = 6;
int n_text_layer = 4;
int n_mels = 80;
int f16 = 1;
};
}<|fim_prefix|>#pragma once
namespace Whisper
{
// default hp<|fim_middle|>arams (Whisper tiny)
struct sModelParams
{
int n_vocab = 51864;
int n_audi... | fim | Const-me/Whisper | c |
#pragma once
#include <stdint.h>
namespace Whisper
{
using whisper_token = int;
struct sTokenData
{
whisper_token id; // token id
whisper_token tid; // forced timestamp token id
float p; // probability of the token
float pt; // probability of the timestamp token
float ptsum; // ... | fim | Const-me/Whisper | c |
<|fim_prefix|>#include "stdafx.h"
#include "voiceActivityDetection.h"
using namespace Whisper;
// Initially ported (poorly) from there https://github.com/panmasuo/voice-activity-detection MIT license
// The code is based on that ar<|fim_suffix|> the updated detection state back into that field
state.currThresh = curr... | fim | Const-me/Whisper | cpp |
#pragma once
#include <complex>
#include <memory>
#include "audioConstants.h"
namespace Whisper
{
class VAD
{
using cplx = std::complex<float>;
std::unique_ptr<cplx[]> fft_signal;
struct Feature
{
float energy;
float F;
float SFM;
};
const Feature primThresh;
static Feature defaultPrimaryThre... | fim | Const-me/Whisper | c |
<|fim_prefix|>#include "stdafx.h"
#include "modelFactory.h"
#include "API/iContext.cl.h"
HRESULT COMLIGHTCALL Whisper::loadModel( const wchar_t* path, const sModelSetup& setup, const sLoadModelCallbacks* callbacks, iModel** pp )
{
switch( setup.impl )
{
case eModelImplementation::GPU:
<|fim_suffix|>use any flags,... | fim | Const-me/Whisper | cpp |
<|fim_suffix|>;
HRESULT __stdcall loadReferenceCpuModel( const wchar_t* path, iModel** pp );
}<|fim_prefix|>#pragma once
#include "API/sLoadModelCallbacks.h"
#include<|fim_middle|> "API/sModelSetup.h"
namespace Whisper
{
struct iModel;
HRESULT __stdcall loadGpuModel( const wchar_t* path, const sModelSetup& setup,... | fim | Const-me/Whisper | c |
<|fim_prefix|>//{{NO_DEPENDENCIES}}
// Microsoft Visual C++ generated include file.
// Used by Resource.rc
// Next default values for new objects
//
#ifdef APSTUDIO_INVOKED<|fim_suffix|>LY_SYMBOLS
#define _APS_NEXT_RESOURCE_VALUE 101
#define _APS_NEXT_COMMAND_VALUE 40001
#define _APS_NEXT_CONTROL_VALUE... | fim | Const-me/Whisper | c |
<|fim_prefix|>#pragma once
//
// GGML Tensor Library
//
// This documentation is still a work in progress.
// If you wish some specific topics to be covered, feel free to drop a comment:
//
// https://github.com/ggerganov/whisper.cpp/issues/40
//
// ## Overview
//
// This library implements:
//
// - a set of tensor... | fim | Const-me/Whisper | c |
<|fim_suffix|>truct whisper_context * ctx,
struct whisper_full_params params,
const float * samples,
int n_samples);
// Split the input audio in chunks and process each chunk separately using whisper_full()
// It seems this approach ... | fim | Const-me/Whisper | c |
<|fim_prefix|>#include "stdafx.h"
#if BUILD_BOTH_VERSIONS
#include "../API/iContext.cl.h"
#include "convertThings.h"
using namespace Whisper;
sFullParams makeNewParams( const whisper_full_params& wfp )
{
assert( nullptr == wfp.encoder_begin_callback );
assert( nullptr == wfp.new_segment_callback );
sFullParams res... | fim | Const-me/Whisper | cpp |
<|fim_suffix|>keOldParams( const Whisper::sFullParams& rsi, Whisper::iContext* context );
HRESULT makeNewResults( whisper_context* ctx, Whisper::eResultFlags flags, Whisper::iTranscribeResult** pp );<|fim_prefix|>#pragma once
#include "../source/whisper.h"
#include "../API/sFullParams.h"
#include "../API/iTranscribeRe... | fim | Const-me/Whisper | c |
#include <stdint.h>
#include <immintrin.h>
#include <stdio.h>
#include <assert.h>
#include "../source/ggml.h"
__forceinline float _cvtsh_ss( uint16_t f16 )
{
__m128i i = _mm_cvtsi32_si128( f16 );
__m128 f = _mm_cvtph_ps( i );
return _mm_cvtss_f32( f );
}
__forceinline uint16_t _cvtss_sh( float f, int rounding )
{
... | fim | Const-me/Whisper | c |
<|fim_prefix|>#i<|fim_suffix|>stdafx.h"<|fim_middle|>nclude "<|endoftext|> | fim | Const-me/Whisper | cpp |
<|fim_suffix|>ing things it streams gigabytes of data into that binary file.
// See Tools / compareTraces project for a command-line app to compare these traces.
#define SAVE_DEBUG_TRACE 0
// Initialize tensors with NaN numbers, and test for NaN values in the outputs tensors
// Incompatible with SAVE_DEBUG_TRACE macro... | fim | Const-me/Whisper | c |
<|fim_suffix|>xt_state;
dp.n_head = hparams.n_text_head;
dp.n_ctx = hparams.n_text_ctx;
dp.n_past = n_past;
dp.M = wctx.exp_n_audio_ctx > 0 ? wctx.exp_n_audio_ctx : hparams.n_audio_ctx;
dp.n_text_layer = hparams.n_text_layer;
dp.n_vocab = hparams.n_vocab;
}
WhisperContext& ctx = WhisperContext::current()... | fim | Const-me/Whisper | cpp |
<|fim_suffix|> "The device has no endpoint ID" );
}
/// <summary>Returns a String which represents the object instance</summary>
public override string ToString() => $"Capture device: \"{displayName}\"";
}
}<|fim_prefix|>using System;
using Whisper.Internal;
namespace Whisper
{
/// <summary>Identifiers for a... | fim | Const-me/Whisper | csharp |
<|fim_suffix|>eamSearch beamSearch;
// [EXPERIMENTAL] speed-up techniques
/// <summary>overwrite the audio context size (0 = use default)</summary>
public int audioContextSize;
}
}<|fim_prefix|>// Missing XML comment for publicly visible type or member
// TODO: remove this line and document them.
#pragma warni... | fim | Const-me/Whisper | csharp |
<|fim_prefix|>namespace Whisper
{
/// <summary>Special tokens defined in the model</summary>
public readonly struct SpecialTokens
{
/// <summary>The end of a transcription</summary>
public readonly int TranscriptionEnd; // token_eot
/// <summary>Start of a transcription</summary>
public readonly int Transcr... | fim | Const-me/Whisper | csharp |
using System;
namespace Whisper
{
/// <summary>Status of the voice capture</summary>
[Flags]
public enum eCaptureStatus: byte
{
/// <summary>Doing nothing</summary>
None = 0,
/// <summary>Capturing the audio</summary>
Listening = 1,
/// <summary>A voice is detected in the captured audio, recording</summ... | fim | Const-me/Whisper | csharp |
<|fim_suffix|>remarks>Incompatible with <see cref="Wave64" /></remarks>
Wave32 = 1,
/// <summary>Use Wave64 version of compute shaders even on nVidia and Intel GPUs</summary>
/// <remarks>Incompatible with <see cref="Wave32" /></remarks>
Wave64 = 2,
/// <summary>Do not use reshaped matrix multiplication sha... | fim | Const-me/Whisper | csharp |
<|fim_prefix|>// This file is generated by a tool, from the `languageCodez.tsv` file in this repository
namespace Whisper
{
/// <summary>Supported languages</summary>
/// <remarks>The values of this enum are zero-padded ASCII strings.<br/>
/// It seems OpenAI tried to implement ISO 639-1, but they used the version o... | fim | Const-me/Whisper | csharp |
<|fim_prefix|>using System;
namespace Whisper
{
/// <summary>Message log level</summary>
public enum eLogLevel: byte
{
/// <summary>Error message</summary>
Error = 0,
/// <summary>Warning message</summary>
Warning = 1,
/// <summary>Informational message</summary>
Info = 2,
/// <summary>Debug message<... | fim | Const-me/Whisper | csharp |
<|fim_prefix|>namespace Whisper
{
/// <summary>Implementation value for the <see cref="Library.loadModel(string, eGpuModelFlags, string?, eModelImplementation)" /> factory function</summary>
public enum eModelImplementation: uint
{
/// <summary>GPGPU implementation based on Direct3D 11.0 compute shaders</summary>... | fim | Const-me/Whisper | csharp |
<|fim_suffix|>Flags)" /> method.</remarks>
NewObject = 0x100,
}
}<|fim_prefix|>using System;
namespace Whisper
{
/// <summary>Flags for <see cref="Context.results(eResultFlags)" /> method</summary>
[Flags]
public enum eResultFlags: uint
{
/// <summary>No flags</summary>
None = 0,
/// <summary>Return ind... | fim | Const-me/Whisper | csharp |
<|fim_suffix|>as 1 channel</summary>
NoStereoData = 0xFF,
}
}<|fim_prefix|>namespace Whisper
{
/// <summary>Output value for iContext.detectSpeaker method</summary>
public enum eSpeakerChannel: byte
{
/// <summary>Unable to detect</summary>
Unsure = 0,
/// <summary>The speech was mostly in the left channel... | fim | Const-me/Whisper | csharp |
<|fim_suffix|> Or better yet, move the data to unmanaged buffer allocated with <see cref="Marshal.AllocHGlobal(int)" /> or <see cref="Marshal.AllocCoTaskMem(int)" /> method.</remarks>
IntPtr getPcmMono();
/// <summary>Unmanaged pointer to the internal buffer with interleaved stereo <c>float</c> PCM samples @ 16 kH... | fim | Const-me/Whisper | csharp |
<|fim_prefix|>using<|fim_suffix|>
}
/// <summary>Audio capture reader object</summary>
/// <remarks>This interface has no public methods callable from C#.<br/>
/// It’s only here to pass data between different functions implemented in C++.</remarks>
[ComInterface( "747752c2-d9fd-40df-8847-583c781bf013", eMarshal... | fim | Const-me/Whisper | csharp |
<|fim_prefix|>using ComLight;
using System;
using System.ComponentModel;
using System.Runtime.InteropServices;
using Whisper.Internal;
namespace Whisper
{
/// <summary>Exposes a small subset of MS Media Foundation framework.</summary>
/// <remarks>That framework is a part of Windows OS, since Vista.</remarks>
/// ... | fim | Const-me/Whisper | csharp |
<|fim_prefix|>using ComLight;
using System;
using System.ComponentModel;
using System.Runtime.InteropServices;
namespace Whisper
{
/// <summary>Function pointer to receive array of tokens from <see cref="iModel.tokenize" /></summary>
[UnmanagedFunctionPointer( CallingConvention.StdCall )]
public delegate void pfnD... | fim | Const-me/Whisper | csharp |
<|fim_prefix|>using System;
namespace Whisper
{
/// <summary>Flags for the audio capture</summary>
[Flags]
public enum eCaptureFlags: uint
{
/// <summary>No special flags</summary>
None = 0,
/// <summary>When the capture device supports stereo, keep stereo PCM samples in addition to mono</sum<|fim_suffix|>1... | fim | Const-me/Whisper | csharp |
<|fim_suffix|>mbly: ComVisible( false )]
[assembly: AssemblyVersion( "1.12.0.0" )]<|fim_prefix|>using Syst<|fim_middle|>em.Reflection;
using System.Runtime.InteropServices;
[assembly: AssemblyCopyright( "Copyright © const.me, 2022-2023" )]
[asse<|endoftext|> | fim | Const-me/Whisper | csharp |
<|fim_prefix|>using System.Reflection;
u<|fim_suffix|>ime.InteropServices;
[assembly: AssemblyTitle( "WhisperNet" )]
[assembly: AssemblyDescription( "DirectCompute port of whisper.cpp library, C# bindings" )]
[assembly: Guid( "ced6cdb7-e040-4398-bae8-3417e5fa35f1" )]<|fim_middle|>sing System.Runt<|endoftext|> | fim | Const-me/Whisper | csharp |
<|fim_suffix|>emarks>
protected virtual bool onEncoderBegin( Context sender ) { return true; }
/// <summary>This callback is called on each new segment</summary>
protected virtual void onNewSegment( Context sender, int countNew ) { }
const int S_OK = 0;
const int S_FALSE = 1;
internal int encoderBegin( Co... | fim | Const-me/Whisper | csharp |
<|fim_prefix|>using Whisper.Internal;
namespace Whisper
{
/// <summary>Implement this abstract class to provide callbacks for audio capture method</summary>
public abstract class CaptureCallbacks
{
/// <summary>Override this method to support cancellation</summary>
protected virtual bool shouldCancel( Context ... | fim | Const-me/Whisper | csharp |
<|fim_prefix|>using System.Diagnostics;
using Whisper.Internal;
using Whisper.Internals;
namespace Whisper
{
/// <summary>Stateful context, contains methods to transcribe audio</summary>
public sealed class Context: IDisposable
{
iContext context;
// Caching the results object here saves time spent in ComLight... | fim | Const-me/Whisper | csharp |
<|fim_prefix|>using System.Diagnostics;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using Whisper.Internal;
namespace Whisper
{
/// <summary>Extension methods of these COM interfaces</summary>
public static class ExtensionMethods
{
/// <summary>Create a context to transcribe audi... | fim | Const-me/Whisper | csharp |
<|fim_suffix|> throw new ApplicationException( text, ex );
}
// We don’t have any additional info about the exception.
// Throw an exception from just the HRESULT code.
Marshal.ThrowExceptionForHR( hr );
}
/// <summary>Called internally by ComLight runtime</summary>
[MethodImpl( MethodImplOptions.Ag... | fim | Const-me/Whisper | csharp |
<|fim_suffix|>hannel detectSpeaker( [In] ref sTimeInterval interval );
/// <summary>Get the model which was used to create this context</summary>
[RetValIndex]
iModel getModel();
/// <summary>Full the default parameters of the model, for the specified sampling strategy</summary>
[RetValIndex( 1 )]
sFullPa... | fim | Const-me/Whisper | csharp |
<|fim_suffix|>p tokens</summary>
public readonly float ptsum;
/// <summary>Voice length of the token</summary>
public readonly float vlen;
/// <summary>Token id</summary>
public readonly int id;
/// <summary>Token flags</summary>
readonly eTokenFlags flags;
/// <summary>True if the token flags has the s... | fim | Const-me/Whisper | csharp |
<|fim_suffix|>ic delegate int pfnCaptureStatus( IntPtr pv, eCaptureStatus status );
/// <summary>Capture callbacks for unmanaged code</summary>
public struct sCaptureCallbacks
{
/// <summary>Cancellation function pointer</summary>
public pfnShouldCancel shouldCancel;
/// <summary>Capture status function point... | fim | Const-me/Whisper | csharp |
<|fim_prefix|>#pragma warning disable CS0649 // Field is never assigned to
using System.Runtime.InteropServices;
name<|fim_suffix|>summary>
public string? endpoint => Marshal.PtrToStringUni( m_endpoint );
}
/// <summary>Function pointer to consume a list of audio capture device IDs</summary>
[UnmanagedFunctionP... | fim | Const-me/Whisper | csharp |
<|fim_prefix|>#pragma warning disable CS0649 // Field is never assigned to
// Missing XML comment for publicly visible type or member
// TODO: remove this line and document them.
#pragma warning disable CS1591
using System.Runtime.InteropServices;
namespace Whisper.Internals
{
/// <summary>This callback is called... | fim | Const-me/Whisper | csharp |
<|fim_prefix|>using System.Runtime.InteropServices;
namespace Whisper.Internal
{
/// <summary>Function pointer to report model loading progress</summary>
[UnmanagedFunctionPointer( CallingConvention.StdCall )]
delegate int pfnLoadProgress( double progress, IntPtr pv );
/// <summary>Function pointer to implement ... | fim | Const-me/Whisper | csharp |
<|fim_suffix|> lvl, [MarshalAs( UnmanagedType.LPUTF8Str )] string message );
struct sLoggerSetup
{
[MarshalAs( UnmanagedType.FunctionPtr )]
public pfnLoggerSink sink;
IntPtr context;
public eLogLevel level;
public eLoggerFlags flags;
}
}<|fim_prefix|>using System;
using System.Runtime.InteropServices;
n... | fim | Const-me/Whisper | csharp |
<|fim_prefix|>using System.Runtime.InteropServices;
namespace Whisper.Internal
{
struct sModelSetup
{
eModelImplemen<|fim_suffix|>tation impl, string? adapter )
{
this.impl = impl;
this.flags = flags;
this.adapter = adapter;
}
}
[UnmanagedFunctionPointer( CallingConvention.StdCall )]
delegate voi... | fim | Const-me/Whisper | csharp |
<|fim_prefix|>#pragma warning disable CS0649 // Field is never assigned to
using System.Runtime.InteropServices;
namespace Whisper.Internal
{
/// <su<|fim_suffix|>
/// <summary>Last parameter to the callback</summary>
internal IntPtr pv;
}
}<|fim_middle|>mmary>A callback to get notified about the progress</su... | fim | Const-me/Whisper | csharp |
<|fim_suffix|> return list.ToArray();
}
}
}<|fim_prefix|>using ComLight;
using System.Diagnostics;
using System.Runtime.InteropServices;
using System.Runtime.Intrinsics.X86;
using Whisper.Internal;
namespace Whisper
{
/// <summary>Factory methods implemented by the C++ DLL</summary>
public static class Library
... | fim | Const-me/Whisper | csharp |
<|fim_prefix|>using System;
using System.IO;
using System.Management.Automation;
namespace Whisper
{
/// <summary>Base class for commands which export results into some text-based format</summary>
public abstract class ExportBase: PSCmdlet
{
/// <summary>
/// <para type="synopsis">Transcribe result produced by... | fim | Const-me/Whisper | csharp |
<|fim_prefix|>using System;
using System.Globalization;
using System.IO;
using System.Management.Automation;
namespace Whisper
{
/// <summary>
/// <para type="synopsis">Write transcribe results into SubRip format.</para>
/// <para type="description">The format is documented there: https://en.wikipedia.org/wiki/<|f... | fim | Const-me/Whisper | csharp |
<|fim_suffix|>ath transcript.txt -timestamps</code></example>
[Cmdlet( VerbsData.Export, "Text" )]
public sealed class ExportText: ExportBase
{
/// <summary>
/// <para type="synopsis">Specify this switch to include timestamps</para>
/// </summary>
[Parameter]
public SwitchParameter timestamps { get; set; }... | fim | Const-me/Whisper | csharp |
<|fim_prefix|>using System;
using System.Globalization;
using System.IO;
using System.Management.Automation;
na<|fim_suffix|>mary>
/// <para type="synopsis">Write transcribe results into WebVTT format.</para>
/// <para type="description">The format is documented there: https://en.wikipedia.org/wiki/WebVTT</para>
/... | fim | Const-me/Whisper | csharp |
<|fim_suffix|>value of the correct type</para>
/// </summary>
[Parameter( Mandatory = true, ValueFromPipeline = true )]
public Transcription source { get; set; }
/// <summary>Performs execution of the command</summary>
protected override void ProcessRecord()
{
var res = source.getResult();
foreach( v... | fim | Const-me/Whisper | csharp |
<|fim_suffix|>
[Cmdlet( VerbsCommon.Get, "Adapters" )]
public sealed class ListAdapters: Cmdlet
{
/// <summary>Performs execution of the command</summary>
protected override void ProcessRecord()
{
string[] arr = Library.listGraphicAdapters();
foreach( string item in arr )
WriteObject( item );
}
}
... | fim | Const-me/Whisper | csharp |
<|fim_suffix|>his.setupLog() )
{
iMediaFoundation mf = Library.initMediaFoundation();
iModel model = Library.loadModel( path, flags, adapter, reportProgress );
WriteObject( new Model( mf, model ) );
}
}
}
}<|fim_prefix|>using System;
using System.IO;
using System.Management.Automation;
namespace ... | fim | Const-me/Whisper | csharp |
<|fim_suffix|>;
}
catch( Exception ex )
{
return ex.HResult;
}
};
return res;
}
}
}<|fim_prefix|>using System;
using System.Management.Automation;
using Whisper.Internal;
namespace Whisper
{
/// <summary>Base class for transcribing cmdlets, it contains a few common parameters</summary>... | fim | Const-me/Whisper | csharp |
<|fim_prefix|>using System;
using System.IO;
using System.Management.Automation;
using Whisper.Internal;
using Whisper.Internals;
namespace Whisper
{
/// <summary>
/// <para type="synopsis">Transcribe audio file from disk</para>
/// </summary<|fim_suffix|> validateLanguage();
promptTokens = null;
if( !stri... | fim | Const-me/Whisper | csharp |
<|fim_suffix|>nal
{
static class MarshalEx
{
/// <summary>Workaround for the missing <c>Marshal.PtrToStringUTF8</c> method</summary>
public static string PtrToStringUTF8( IntPtr ptr )
{
if( ptr != IntPtr.Zero )
{
unsafe
{
byte* stringStart = (byte*)ptr;
byte* stringEnd = stringStart;
... | fim | Const-me/Whisper | csharp |
<|fim_prefix|>using System;
using System.Runtime.CompilerServices;
using System.Runtime.ExceptionServices;
using System.Runtime.InteropServices;
namespace Whisper.Internal
{
/// <summary>Utility class to supply logging function pointer to the C++ library,<br/>
/// and provide custom calling conventions to ComLight ... | fim | Const-me/Whisper | csharp |
<|fim_suffix|>
/// <summary>Start and end times of the token</summary>
public readonly sTimeInterval time;
/// <summary>Probability of the token</summary>
public readonly float probability;
/// <summary>Probability of the timestamp token</summary>
public readonly float probabilityTimestamp;
/// <summary>S... | fim | Const-me/Whisper | csharp |
<|fim_suffix|>stem, but is not a readable string.</summary>
public string endpoint => Marshal.PtrToStringUni( m_endpoint );
}
/// <summary>Function pointer to consume a list of audio capture device IDs</summary>
[UnmanagedFunctionPointer( CallingConvention.StdCall )]
public delegate int pfnFoundCaptureDevices( i... | fim | Const-me/Whisper | csharp |
<|fim_suffix|>ctionPtr )]
internal pfnNewSegment newSegmentCallback;
/// <summary>Parameter for the above, not needed in C#</summary>
internal IntPtr newSegmentCallbackData;
/// <summary>The callback is called before every encoder run. If it returns false, the processing is aborted</summary>
[MarshalAs( Unma... | fim | Const-me/Whisper | csharp |
<|fim_suffix|>se
progress = null;
pv = IntPtr.Zero;
}
}
}<|fim_prefix|>using System;
using System.Runtime.InteropServices;
using System.Threading;
namespace Whisper.Internal
{
/// <summary>Function pointer to report model loading progress</summary>
[UnmanagedFunctionPointer( CallingConvention.StdCall )]
... | fim | Const-me/Whisper | csharp |
<|fim_prefix|>using System;
using System.Runtime.InteropServices;
namespace Whisper.Internal
{
struc<|fim_suffix|>uModelFlags flags, eModelImplementation impl, string adapter )
{
this.impl = impl;
this.flags = flags;
this.adapter = adapter;
}
}
[UnmanagedFunctionPointer( CallingConvention.StdCall )]
... | fim | Const-me/Whisper | csharp |
<|fim_prefix|>#pragma warning disable CS0649 // Field is never assigned to
u<|fim_suffix|>rogress( double value, IntPtr context, IntPtr pv );
/// <summary>C structure with a progress reporting function pointer</summary>
public struct sProgressSink
{
/// <summary>A callback to get notified about the progress</su... | fim | Const-me/Whisper | csharp |
<|fim_suffix|>> tcs = new TaskCompletionSource<iModel>();
WaitCallback wcb = delegate ( object state )
{
try
{
sModelSetup setup = new sModelSetup( flags, impl, adapter );
sLoadModelCallbacks callbacks = new sLoadModelCallbacks( cancelToken, pfnProgress );
iModel model;
NativeLogger.... | fim | Const-me/Whisper | csharp |
<|fim_prefix|>using System.Reflection;
using System.Runtime.InteropServices;
[assembly: AssemblyTi<|fim_suffix|>hell 5.1 bindings" )]
[assembly: Guid( "6909b760-ff72-48f5-8493-2e956cbb7cec" )]<|fim_middle|>tle( "WhisperPS" )]
[assembly: AssemblyDescription( "DirectCompute port of whisper.cpp library, PowerS<|endoftex... | fim | Const-me/Whisper | csharp |
<|fim_suffix|>ay exceed 4GB of video memory</para>
/// </summary>
public sealed class Model: IDisposable
{
internal iMediaFoundation mf { get; private set; }
internal iModel model { get; private set; }
internal Model( iMediaFoundation mf, iModel model )
{
this.mf = mf;
this.model = model;
}
publi... | fim | Const-me/Whisper | csharp |
<|fim_suffix|>meSpan Begin { get; }
/// <summary>Timestamp of the end of the segment, since the start of the media</summary>
public TimeSpan End { get; }
/// <summary>Text of the segment</summary>
public string Text { get; }
/// <summary>A string representation of this object</summary>
public override str... | fim | Const-me/Whisper | csharp |
<|fim_suffix|>public string Source { get; }
/// <summary>Source file name, no extension</summary>
public string SourceName =>
Path.GetFileNameWithoutExtension( Source );
/// <summary>Text of the complete transcription</summary>
public string Text => makeText();
}
}<|fim_prefix|>using System;
using System... | fim | Const-me/Whisper | csharp |
<|fim_prefix|>using System;
using System.Management.Automation;
namespace Whisper
{
static class CommandLogger
{
static CommandLogger()
{
Library.setLogSink( eLogLevel.Debug, eLoggerFlags.SkipFormatM<|fim_suffix|>( level )
{
case eLogLevel.Warning:
cmdlet?.WriteWarning( message );
break;
... | fim | Const-me/Whisper | csharp |
<|fim_suffix|> return false;
if( pathRoot[ 0 ] != '\\' || pathRoot[ 1 ] != '\\' )
return true; // Rooted and not a UNC path
return pathRoot.Trim( '\\' ).IndexOf( '\\' ) != -1; // A UNC server name without a share name (e.g "\\NAME" or "\\NAME\") is invalid
}
static string currentDirectory( this PSCmd... | fim | Const-me/Whisper | csharp |
<|fim_suffix|>rn 0
if __name__ == "__main__":
target = (
sys.argv[1]
if len(sys.argv) > 1
else os.environ.get("JUNIT_OUT", "reports/junit-nl-suite.xml")
)
raise SystemExit(main(target))
<|fim_prefix|>#!/usr/bin/env python3
"""
Post-processes a JUnit XML so that "expected"/environme... | fim | CoplayDev/unity-mcp | python |
<|fim_suffix|> {
Debug.LogWarning($"[MCP] No MonoBehaviour types found in {assemblyName} to attach");
}
}
else
{
Debug.LogWarning($"[MCP] GameObject '{attachTo}' not fo... | fim | CoplayDev/unity-mcp | csharp |
<|fim_suffix|>ory Entries:", EditorStyles.boldLabel);
historyScroll = EditorGUILayout.BeginScrollView(historyScroll);
for (int i = history.Count - 1; i >= 0; i--) // Reverse order (newest first)
{
var entry = history[i];
GUIStyle entryStyle = new GUIStyle(GUI.ski... | fim | CoplayDev/unity-mcp | csharp |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.