Skip to content

Commit 4bc1986

Browse files
authored
fix: Remove duplicated native function in ArrayUtils.kt (#106)
## Description <!-- Provide a concise and descriptive summary of the changes implemented in this PR. --> ### Type of change - [x] Bug fix (non-breaking change which fixes an issue) - [ ] New feature (non-breaking change which adds functionality) - [ ] Breaking change (fix or feature that would cause existing functionality to not work as expected) - [ ] Documentation update (improves or adds clarity to existing documentation) ### Tested on - [ ] iOS - [ ] Android ### Testing instructions <!-- Provide step-by-step instructions on how to test your changes. Include setup details if necessary. --> ### Screenshots <!-- Add screenshots here, if applicable --> ### Related issues <!-- Link related issues here using #issue-number --> ### Checklist - [ ] I have performed a self-review of my code - [ ] I have commented my code, particularly in hard-to-understand areas - [ ] I have updated the documentation accordingly - [ ] My changes generate no new warnings ### Additional notes <!-- Include any additional information, assumptions, or context that reviewers might need to understand this PR. -->
1 parent 80721ec commit 4bc1986

File tree

3 files changed

+6
-16
lines changed

3 files changed

+6
-16
lines changed

android/src/main/java/com/swmansion/rnexecutorch/models/BaseModel.kt

+1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import android.content.Context
44
import com.swmansion.rnexecutorch.utils.ETError
55
import org.pytorch.executorch.EValue
66
import org.pytorch.executorch.Module
7+
import org.pytorch.executorch.Tensor
78
import java.net.URL
89

910

android/src/main/java/com/swmansion/rnexecutorch/utils/ArrayUtils.kt

-3
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,6 @@ class ArrayUtils {
1919
fun createCharArray(input: ReadableArray): CharArray {
2020
return createTypedArrayFromReadableArray(input) { array, index -> array.getInt(index).toChar() }.toCharArray()
2121
}
22-
fun createByteArray(input: ReadableArray): ByteArray {
23-
return createTypedArrayFromReadableArray(input) { array, index -> array.getInt(index).toByte() }.toByteArray()
24-
}
2522
fun createIntArray(input: ReadableArray): IntArray {
2623
return createTypedArrayFromReadableArray(input) { array, index -> array.getInt(index) }.toIntArray()
2724
}

src/SpeechToTextController.ts

+5-13
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,10 @@ import {
44
AudioBuffer,
55
} from 'react-native-audio-api';
66
import { _SpeechToTextModule } from './native/RnExecutorchModules';
7-
import { EventSubscription, Image } from 'react-native';
7+
import { EventSubscription } from 'react-native';
88
import { SpeechToText } from './native/RnExecutorchModules';
99
import * as FileSystem from 'expo-file-system';
10+
import { fetchResource } from './utils/fetchResource';
1011
import decoder from './decoders/WhisperDecodings';
1112

1213
type ModelSource = string | number;
@@ -50,20 +51,11 @@ export class SpeechToTextController {
5051
encoderSource: ModelSource,
5152
decoderSource: ModelSource
5253
) {
53-
let preprocessorPath = preprocessorSource;
54-
let encoderPath = encoderSource;
55-
let decoderPath = decoderSource;
56-
if (
57-
typeof encoderSource === 'number' &&
58-
typeof decoderSource === 'number' &&
59-
typeof preprocessorSource === 'number'
60-
) {
61-
encoderPath = Image.resolveAssetSource(encoderSource).uri;
62-
decoderPath = Image.resolveAssetSource(decoderSource).uri;
63-
preprocessorPath = Image.resolveAssetSource(preprocessorSource).uri;
64-
}
6554
try {
6655
this.isReady = false;
56+
const preprocessorPath = await fetchResource(preprocessorSource);
57+
const encoderPath = await fetchResource(encoderSource);
58+
const decoderPath = await fetchResource(decoderSource);
6759
await this.nativeModule.loadModule(
6860
preprocessorPath,
6961
encoderPath,

0 commit comments

Comments
 (0)