Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import android.content.Context
import com.swmansion.rnexecutorch.utils.ETError
import org.pytorch.executorch.EValue
import org.pytorch.executorch.Module
import org.pytorch.executorch.Tensor
import java.net.URL


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,6 @@ class ArrayUtils {
fun createCharArray(input: ReadableArray): CharArray {
return createTypedArrayFromReadableArray(input) { array, index -> array.getInt(index).toChar() }.toCharArray()
}
fun createByteArray(input: ReadableArray): ByteArray {
return createTypedArrayFromReadableArray(input) { array, index -> array.getInt(index).toByte() }.toByteArray()
}
fun createIntArray(input: ReadableArray): IntArray {
return createTypedArrayFromReadableArray(input) { array, index -> array.getInt(index) }.toIntArray()
}
Expand Down
18 changes: 5 additions & 13 deletions src/SpeechToTextController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@ import {
AudioBuffer,
} from 'react-native-audio-api';
import { _SpeechToTextModule } from './native/RnExecutorchModules';
import { EventSubscription, Image } from 'react-native';
import { EventSubscription } from 'react-native';
import { SpeechToText } from './native/RnExecutorchModules';
import * as FileSystem from 'expo-file-system';
import { fetchResource } from './utils/fetchResource';
import decoder from './decoders/WhisperDecodings';

type ModelSource = string | number;
Expand Down Expand Up @@ -50,20 +51,11 @@ export class SpeechToTextController {
encoderSource: ModelSource,
decoderSource: ModelSource
) {
let preprocessorPath = preprocessorSource;
let encoderPath = encoderSource;
let decoderPath = decoderSource;
if (
typeof encoderSource === 'number' &&
typeof decoderSource === 'number' &&
typeof preprocessorSource === 'number'
) {
encoderPath = Image.resolveAssetSource(encoderSource).uri;
decoderPath = Image.resolveAssetSource(decoderSource).uri;
preprocessorPath = Image.resolveAssetSource(preprocessorSource).uri;
}
try {
this.isReady = false;
const preprocessorPath = await fetchResource(preprocessorSource);
const encoderPath = await fetchResource(encoderSource);
const decoderPath = await fetchResource(decoderSource);
await this.nativeModule.loadModule(
preprocessorPath,
encoderPath,
Expand Down