@@ -16,14 +16,15 @@ class WhisperContext
1616 /**
1717 * Create a new WhisperContext from a file, with parameters.
1818 *
19- * @param string $modelPath The path to the model file.
20- * @param WhisperContextParameters|null $params A parameter struct containing the parameters to use.
19+ * @param string $modelPath The path to the model file.
20+ * @param WhisperContextParameters|null $params A parameter struct containing the parameters to use.
2121 *
2222 * @throws WhisperException
2323 */
2424 public function __construct (string $ modelPath , ?WhisperContextParameters $ params = null )
2525 {
26- $ this ->ffi = LibraryLoader::getInstance ('whisper ' );
26+ $ libraryLoader = new LibraryLoader ();
27+ $ this ->ffi = $ libraryLoader ->get ('whisper ' );
2728
2829 $ this ->setupLoggerCallback ();
2930
@@ -51,8 +52,8 @@ public function createState(): WhisperState
5152 /**
5253 * Convert the provided text into tokens.
5354 *
54- * @param string $text The text to convert.
55- * @param int $maxTokens The maximum number of tokens to return.
55+ * @param string $text The text to convert.
56+ * @param int $maxTokens The maximum number of tokens to return.
5657 */
5758 public function tokenize (string $ text , int $ maxTokens ): array
5859 {
@@ -109,7 +110,7 @@ public function nAudioCtx(): int
109110 */
110111 public function isMultilingual (): bool
111112 {
112- return (bool ) $ this ->ffi ->whisper_is_multilingual ($ this ->ctx );
113+ return (bool )$ this ->ffi ->whisper_is_multilingual ($ this ->ctx );
113114 }
114115
115116 /**
@@ -178,7 +179,7 @@ public function modelType(): int
178179 /**
179180 * Convert a token ID to a string.
180181 *
181- * @param int $tokenId The ID of the token to convert.
182+ * @param int $tokenId The ID of the token to convert.
182183 */
183184 public function tokenToStr (int $ tokenId ): string
184185 {
@@ -262,7 +263,7 @@ public function tokenBeg(): int
262263 /**
263264 * Get the ID of a specified language token
264265 *
265- * @param int $langId The ID of the language
266+ * @param int $langId The ID of the language
266267 */
267268 public function tokenLang (int $ langId ): int
268269 {
@@ -272,7 +273,7 @@ public function tokenLang(int $langId): int
272273 /**
273274 * Return the id of the specified language, returns -1 if not found
274275 *
275- * @param string $lang The language to get the ID of
276+ * @param string $lang The language to get the ID of
276277 */
277278 public function langId (string $ lang ): int
278279 {
@@ -292,7 +293,7 @@ public function langId(string $lang): int
292293 /**
293294 * Return the short string of the specified language id (e.g. 2 -> "de"), returns nullptr if not found
294295 *
295- * @param int $langId The ID of the language
296+ * @param int $langId The ID of the language
296297 */
297298 public function langStr (int $ langId ): string
298299 {
@@ -302,7 +303,7 @@ public function langStr(int $langId): string
302303 /**
303304 * Return the short string of the specified language name (e.g. 2 -> "german"), returns nullptr if not found
304305 *
305- * @param int $langId The ID of the language
306+ * @param int $langId The ID of the language
306307 */
307308 public function langStrFull (int $ langId ): string
308309 {
@@ -354,7 +355,7 @@ public function nSegments(): int
354355 /**
355356 * Get the text of the segment at the specified index.
356357 *
357- * @param int $index Segment index.
358+ * @param int $index Segment index.
358359 */
359360 public function getSegmentText (int $ index ): string
360361 {
@@ -364,7 +365,7 @@ public function getSegmentText(int $index): string
364365 /**
365366 * Get the start time of the segment at the specified index.
366367 *
367- * @param int $index Segment index.
368+ * @param int $index Segment index.
368369 */
369370 public function getSegmentStartTime (int $ index ): int
370371 {
@@ -374,7 +375,7 @@ public function getSegmentStartTime(int $index): int
374375 /**
375376 * Get the end time of the segment at the specified index.
376377 *
377- * @param int $index Segment index.
378+ * @param int $index Segment index.
378379 */
379380 public function getSegmentEndTime (int $ index ): int
380381 {
@@ -384,7 +385,7 @@ public function getSegmentEndTime(int $index): int
384385 /**
385386 * Get number of tokens in the specified segment.
386387 *
387- * @param int $index Segment index.
388+ * @param int $index Segment index.
388389 */
389390 public function nTokens (int $ index ): int
390391 {
@@ -394,8 +395,8 @@ public function nTokens(int $index): int
394395 /**
395396 * Get the token text of the specified token in the specified segment.
396397 *
397- * @param int $index Segment index.
398- * @param int $token Token index.
398+ * @param int $index Segment index.
399+ * @param int $token Token index.
399400 */
400401 public function tokenText (int $ index , int $ token ): string
401402 {
@@ -416,8 +417,8 @@ public function tokenData(int $index, int $token): ?TokenData
416417 /**
417418 * Get the token ID of the specified token in the specified segment.
418419 *
419- * @param int $index Segment index.
420- * @param int $token Token index.
420+ * @param int $index Segment index.
421+ * @param int $token Token index.
421422 */
422423 public function tokenId (int $ index , int $ token ): int
423424 {
@@ -427,8 +428,8 @@ public function tokenId(int $index, int $token): int
427428 /**
428429 * Get the probability of the specified token in the specified segment.
429430 *
430- * @param int $index Segment index.
431- * @param int $token Token index.
431+ * @param int $index Segment index.
432+ * @param int $token Token index.
432433 */
433434 public function tokenProb (int $ index , int $ token ): float
434435 {
0 commit comments