Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pnpm tauri android build --> mismatches between *const i8 and *const u8 #72

Closed
oddpxl opened this issue Jan 14, 2025 · 11 comments
Closed
Labels
bug Something isn't working

Comments

@oddpxl
Copy link

oddpxl commented Jan 14, 2025

What happened?

pnpm tauri android dev works fine.

..however - pnpm tauri android build --> mismatches between pointer types *const i8 and *const u8

" expected raw pointer *const i8 found raw pointer *const u8 "

Steps to reproduce

  1. pnpm tauri android build
  2. numerous mismatch errors

What OS are you seeing the problem on?

MacOs / MacBookPro M1 Max

Relevant log output

Compiling sherpa-rs v0.6.2 [21s]
error[E0308]: mismatched types[21s]
  -->  /.cargo/registry/src/index.crates.io-6f17d22bba15001f/sherpa-rs-0.6.2/src/audio_tag.rs:36:28
   |
36 |                     model: model.as_ptr(),
   |                            ^^^^^^^^^^^^^^ expected `*const i8`, found `*const u8`
   |
   = note: expected raw pointer `*const i8`
              found raw pointer `*const u8`

error[E0308]: mismatched types
  -->   /.cargo/registry/src/index.crates.io-6f17d22bba15001f/sherpa-rs-0.6.2/src/audio_tag.rs:38:22
   |
38 |                 ced: ced.as_ptr(),
   |                      ^^^^^^^^^^^^ expected `*const i8`, found `*const u8`
   |
   = note: expected raw pointer `*const i8`
              found raw pointer `*const u8`

error[E0308]: mismatched types
  -->   /.cargo/registry/src/index.crates.io-6f17d22bba15001f/sherpa-rs-0.6.2/src/audio_tag.rs:41:27
   |
41 |                 provider: provider.as_ptr(),
   |                           ^^^^^^^^^^^^^^^^^ expected `*const i8`, found `*const u8`
   |
   = note: expected raw pointer `*const i8`
              found raw pointer `*const u8`

error[E0308]: mismatched types
  -->   /.cargo/registry/src/index.crates.io-6f17d22bba15001f/sherpa-rs-0.6.2/src/audio_tag.rs:43:21
   |
43 |             labels: labels.as_ptr(),
   |                     ^^^^^^^^^^^^^^^ expected `*const i8`, found `*const u8`
   |
   = note: expected raw pointer `*const i8`
              found raw pointer `*const u8`

error[E0308]: mismatched types
  -->   /.cargo/registry/src/index.crates.io-6f17d22bba15001f/sherpa-rs-0.6.2/src/audio_tag.rs:75:49
   |
75 |                 let event_name = cstr_to_string((*event).name);
   |                                  -------------- ^^^^^^^^^^^^^ expected `*const u8`, found `*const i8`
   |                                  |
   |                                  arguments to this function are incorrect
   |
   = note: expected raw pointer `*const u8`
              found raw pointer `*const i8`
note: function defined here
  -->   /.cargo/registry/src/index.crates.io-6f17d22bba15001f/sherpa-rs-0.6.2/src/utils.rs:52:8
   |
52 | pub fn cstr_to_string(ptr: *const u8) -> String {
   |        ^^^^^^^^^^^^^^ --------------

error[E0308]: mismatched types
  -->   /.cargo/registry/src/index.crates.io-6f17d22bba15001f/sherpa-rs-0.6.2/src/diarize.rs:67:24
   |
67 |                 model: embedding_model.as_ptr(),
   |                        ^^^^^^^^^^^^^^^^^^^^^^^^ expected `*const i8`, found `*const u8`
   |
   = note: expected raw pointer `*const i8`
              found raw pointer `*const u8`

error[E0308]: mismatched types
  -->   /.cargo/registry/src/index.crates.io-6f17d22bba15001f/sherpa-rs-0.6.2/src/diarize.rs:70:27
   |
70 |                 provider: provider.as_ptr(),
   |                           ^^^^^^^^^^^^^^^^^ expected `*const i8`, found `*const u8`
   |
   = note: expected raw pointer `*const i8`
              found raw pointer `*const u8`

error[E0308]: mismatched types
  -->   /.cargo/registry/src/index.crates.io-6f17d22bba15001f/sherpa-rs-0.6.2/src/diarize.rs:77:28
   |
77 |                     model: segmentation_model.as_ptr(),
   |                            ^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `*const i8`, found `*const u8`
   |
   = note: expected raw pointer `*const i8`
              found raw pointer `*const u8`

error[E0308]: mismatched types
  -->   /.cargo/registry/src/index.crates.io-6f17d22bba15001f/sherpa-rs-0.6.2/src/diarize.rs:81:27
   |
81 |                 provider: provider.as_ptr(),
   |                           ^^^^^^^^^^^^^^^^^ expected `*const i8`, found `*const u8`
   |
   = note: expected raw pointer `*const i8`
              found raw pointer `*const u8`

error[E0308]: mismatched types
  -->   /.cargo/registry/src/index.crates.io-6f17d22bba15001f/sherpa-rs-0.6.2/src/embedding_manager.rs:33:39
   |
33 |             let name = cstr_to_string(name);
   |                        -------------- ^^^^ expected `*const u8`, found `*const i8`
   |                        |
   |                        arguments to this function are incorrect
   |
   = note: expected raw pointer `*const u8`
              found raw pointer `*const i8`
note: function defined here
  -->   /.cargo/registry/src/index.crates.io-6f17d22bba15001f/sherpa-rs-0.6.2/src/utils.rs:52:8
   |
52 | pub fn cstr_to_string(ptr: *const u8) -> String {
   |        ^^^^^^^^^^^^^^ --------------

error[E0308]: mismatched types
  -->   /.cargo/registry/src/index.crates.io-6f17d22bba15001f/sherpa-rs-0.6.2/src/embedding_manager.rs:60:43
   |
60 |                 let name = cstr_to_string(match_c.name);
   |                            -------------- ^^^^^^^^^^^^ expected `*const u8`, found `*const i8`
   |                            |
   |                            arguments to this function are incorrect
   |
   = note: expected raw pointer `*const u8`
              found raw pointer `*const i8`
note: function defined here
  -->   /.cargo/registry/src/index.crates.io-6f17d22bba15001f/sherpa-rs-0.6.2/src/utils.rs:52:8
   |
52 | pub fn cstr_to_string(ptr: *const u8) -> String {
   |        ^^^^^^^^^^^^^^ --------------

error[E0308]: mismatched types
    -->   /.cargo/registry/src/index.crates.io-6f17d22bba15001f/sherpa-rs-0.6.2/src/embedding_manager.rs:74:17
     |
72   |             let status = sherpa_rs_sys::SherpaOnnxSpeakerEmbeddingManagerAdd(
     |                          --------------------------------------------------- arguments to this function are incorrect
73   |                 self.manager,
74   |                 name_c.as_ptr(),
     |                 ^^^^^^^^^^^^^^^ expected `*const i8`, found `*const u8`
     |
     = note: expected raw pointer `*const i8`
                found raw pointer `*const u8`
note: function defined here
    -->     /src-tauri/target/i686-linux-android/release/build/sherpa-rs-sys-9a3b1ba71534b6f6/out/bindings.rs:3138:12
     |
3138 |     pub fn SherpaOnnxSpeakerEmbeddingManagerAdd(
     |            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

error[E0308]: mismatched types
  -->   /.cargo/registry/src/index.crates.io-6f17d22bba15001f/sherpa-rs-0.6.2/src/keyword_spot.rs:81:30
   |
81 |                     encoder: zipformer_encoder.as_ptr(),
   |                              ^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `*const i8`, found `*const u8`
   |
   = note: expected raw pointer `*const i8`
              found raw pointer `*const u8`

error[E0308]: mismatched types
  -->   /.cargo/registry/src/index.crates.io-6f17d22bba15001f/sherpa-rs-0.6.2/src/keyword_spot.rs:82:30
   |
82 |                     decoder: zipformer_decoder.as_ptr(),
   |                              ^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `*const i8`, found `*const u8`
   |
   = note: expected raw pointer `*const i8`
              found raw pointer `*const u8`

error[E0308]: mismatched types
  -->   /.cargo/registry/src/index.crates.io-6f17d22bba15001f/sherpa-rs-0.6.2/src/keyword_spot.rs:83:29
   |
83 |                     joiner: zipformer_joiner.as_ptr(),
   |                             ^^^^^^^^^^^^^^^^^^^^^^^^^ expected `*const i8`, found `*const u8`
   |
   = note: expected raw pointer `*const i8`
              found raw pointer `*const u8`

error[E0308]: mismatched types
  -->   /.cargo/registry/src/index.crates.io-6f17d22bba15001f/sherpa-rs-0.6.2/src/keyword_spot.rs:92:25
   |
92 |                 tokens: tokens.as_ptr(),
   |                         ^^^^^^^^^^^^^^^ expected `*const i8`, found `*const u8`
   |
   = note: expected raw pointer `*const i8`
              found raw pointer `*const u8`

error[E0308]: mismatched types
  -->   /.cargo/registry/src/index.crates.io-6f17d22bba15001f/sherpa-rs-0.6.2/src/keyword_spot.rs:99:27
   |
99 |                 provider: provider.as_ptr(),
   |                           ^^^^^^^^^^^^^^^^^ expected `*const i8`, found `*const u8`
   |
   = note: expected raw pointer `*const i8`
              found raw pointer `*const u8`

error[E0308]: mismatched types
   -->   /.cargo/registry/src/index.crates.io-6f17d22bba15001f/sherpa-rs-0.6.2/src/keyword_spot.rs:103:28
    |
103 |             keywords_file: keywords.as_ptr(),
    |                            ^^^^^^^^^^^^^^^^^ expected `*const i8`, found `*const u8`
    |
    = note: expected raw pointer `*const i8`
               found raw pointer `*const u8`

error[E0308]: mismatched types
   -->   /.cargo/registry/src/index.crates.io-6f17d22bba15001f/sherpa-rs-0.6.2/src/keyword_spot.rs:142:54
    |
142 |                 let decoded_keyword = cstr_to_string((*result_ptr).keyword);
    |                                       -------------- ^^^^^^^^^^^^^^^^^^^^^ expected `*const u8`, found `*const i8`
    |                                       |
    |                                       arguments to this function are incorrect
    |
    = note: expected raw pointer `*const u8`
               found raw pointer `*const i8`
note: function defined here
   -->   /.cargo/registry/src/index.crates.io-6f17d22bba15001f/sherpa-rs-0.6.2/src/utils.rs:52:8
    |
52  | pub fn cstr_to_string(ptr: *const u8) -> String {
    |        ^^^^^^^^^^^^^^ --------------

error[E0308]: mismatched types
  -->   /.cargo/registry/src/index.crates.io-6f17d22bba15001f/sherpa-rs-0.6.2/src/language_id.rs:30:22
   |
30 |             decoder: decoder.as_ptr(),
   |                      ^^^^^^^^^^^^^^^^ expected `*const i8`, found `*const u8`
   |
   = note: expected raw pointer `*const i8`
              found raw pointer `*const u8`

error[E0308]: mismatched types
  -->   /.cargo/registry/src/index.crates.io-6f17d22bba15001f/sherpa-rs-0.6.2/src/language_id.rs:31:22
   |
31 |             encoder: encoder.as_ptr(),
   |                      ^^^^^^^^^^^^^^^^ expected `*const i8`, found `*const u8`
   |
   = note: expected raw pointer `*const i8`
              found raw pointer `*const u8`

error[E0308]: mismatched types
  -->   /.cargo/registry/src/index.crates.io-6f17d22bba15001f/sherpa-rs-0.6.2/src/language_id.rs:37:23
   |
37 |             provider: provider.as_ptr(),
   |                       ^^^^^^^^^^^^^^^^^ expected `*const i8`, found `*const u8`
   |
   = note: expected raw pointer `*const i8`
              found raw pointer `*const u8`

error[E0308]: mismatched types
  -->   /.cargo/registry/src/index.crates.io-6f17d22bba15001f/sherpa-rs-0.6.2/src/language_id.rs:62:43
   |
62 |             let language = cstr_to_string(language_ptr);
   |                            -------------- ^^^^^^^^^^^^ expected `*const u8`, found `*const i8`
   |                            |
   |                            arguments to this function are incorrect
   |
   = note: expected raw pointer `*const u8`
              found raw pointer `*const i8`
note: function defined here
  -->   /.cargo/registry/src/index.crates.io-6f17d22bba15001f/sherpa-rs-0.6.2/src/utils.rs:52:8
   |
52 | pub fn cstr_to_string(ptr: *const u8) -> String {
   |        ^^^^^^^^^^^^^^ --------------

error[E0308]: mismatched types
  -->   /.cargo/registry/src/index.crates.io-6f17d22bba15001f/sherpa-rs-0.6.2/src/moonshine.rs:74:23
   |
74 |             provider: provider_ptr.as_ptr(),
   |                       ^^^^^^^^^^^^^^^^^^^^^ expected `*const i8`, found `*const u8`
   |
   = note: expected raw pointer `*const i8`
              found raw pointer `*const u8`

error[E0308]: mismatched types
  -->   /.cargo/registry/src/index.crates.io-6f17d22bba15001f/sherpa-rs-0.6.2/src/moonshine.rs:77:21
   |
77 |             tokens: tokens_ptr.as_ptr(),
   |                     ^^^^^^^^^^^^^^^^^^^ expected `*const i8`, found `*const u8`
   |
   = note: expected raw pointer `*const i8`
              found raw pointer `*const u8`

error[E0308]: mismatched types
  -->   /.cargo/registry/src/index.crates.io-6f17d22bba15001f/sherpa-rs-0.6.2/src/moonshine.rs:96:31
   |
96 |                 preprocessor: preprocessor_ptr.as_ptr(),
   |                               ^^^^^^^^^^^^^^^^^^^^^^^^^ expected `*const i8`, found `*const u8`
   |
   = note: expected raw pointer `*const i8`
              found raw pointer `*const u8`

error[E0308]: mismatched types
  -->   /.cargo/registry/src/index.crates.io-6f17d22bba15001f/sherpa-rs-0.6.2/src/moonshine.rs:97:26
   |
97 |                 encoder: encoder_ptr.as_ptr(),
   |                          ^^^^^^^^^^^^^^^^^^^^ expected `*const i8`, found `*const u8`
   |
   = note: expected raw pointer `*const i8`
              found raw pointer `*const u8`

error[E0308]: mismatched types
  -->   /.cargo/registry/src/index.crates.io-6f17d22bba15001f/sherpa-rs-0.6.2/src/moonshine.rs:98:35
   |
98 |                 uncached_decoder: uncached_decoder_ptr.as_ptr(),
   |                                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `*const i8`, found `*const u8`
   |
   = note: expected raw pointer `*const i8`
              found raw pointer `*const u8`

error[E0308]: mismatched types
  -->   /.cargo/registry/src/index.crates.io-6f17d22bba15001f/sherpa-rs-0.6.2/src/moonshine.rs:99:33
   |
99 |                 cached_decoder: cached_decoder_ptr.as_ptr(),
   |                                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `*const i8`, found `*const u8`
   |
   = note: expected raw pointer `*const i8`
              found raw pointer `*const u8`

error[E0308]: mismatched types
   -->   /.cargo/registry/src/index.crates.io-6f17d22bba15001f/sherpa-rs-0.6.2/src/moonshine.rs:143:39
    |
143 |             let text = cstr_to_string(raw_result.text);
    |                        -------------- ^^^^^^^^^^^^^^^ expected `*const u8`, found `*const i8`
    |                        |
    |                        arguments to this function are incorrect
    |
    = note: expected raw pointer `*const u8`
               found raw pointer `*const i8`
note: function defined here
   -->   /.cargo/registry/src/index.crates.io-6f17d22bba15001f/sherpa-rs-0.6.2/src/utils.rs:52:8
    |
52  | pub fn cstr_to_string(ptr: *const u8) -> String {
    |        ^^^^^^^^^^^^^^ --------------

error[E0308]: mismatched types
  -->   /.cargo/registry/src/index.crates.io-6f17d22bba15001f/sherpa-rs-0.6.2/src/punctuate.rs:32:33
   |
32 |                 ct_transformer: model.as_ptr(),
   |                                 ^^^^^^^^^^^^^^ expected `*const i8`, found `*const u8`
   |
   = note: expected raw pointer `*const i8`
              found raw pointer `*const u8`

error[E0308]: mismatched types
  -->   /.cargo/registry/src/index.crates.io-6f17d22bba15001f/sherpa-rs-0.6.2/src/punctuate.rs:35:27
   |
35 |                 provider: provider.as_ptr(),
   |                           ^^^^^^^^^^^^^^^^^ expected `*const i8`, found `*const u8`
   |
   = note: expected raw pointer `*const i8`
              found raw pointer `*const u8`

error[E0308]: mismatched types
    -->   /.cargo/registry/src/index.crates.io-6f17d22bba15001f/sherpa-rs-0.6.2/src/punctuate.rs:52:17
     |
50   |             let text_with_punct_ptr = sherpa_rs_sys::SherpaOfflinePunctuationAddPunct(
     |                                       ----------------------------------------------- arguments to this function are incorrect
51   |                 self.audio_punctuation,
52   |                 text.as_ptr(),
     |                 ^^^^^^^^^^^^^ expected `*const i8`, found `*const u8`
     |
     = note: expected raw pointer `*const i8`
                found raw pointer `*const u8`
note: function defined here
    -->     /src-tauri/target/i686-linux-android/release/build/sherpa-rs-sys-9a3b1ba71534b6f6/out/bindings.rs:3679:12
     |
3679 |     pub fn SherpaOfflinePunctuationAddPunct(
     |            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

error[E0308]: mismatched types
  -->   /.cargo/registry/src/index.crates.io-6f17d22bba15001f/sherpa-rs-0.6.2/src/punctuate.rs:54:50
   |
54 |             let text_with_punct = cstr_to_string(text_with_punct_ptr);
   |                                   -------------- ^^^^^^^^^^^^^^^^^^^ expected `*const u8`, found `*const i8`
   |                                   |
   |                                   arguments to this function are incorrect
   |
   = note: expected raw pointer `*const u8`
              found raw pointer `*const i8`
note: function defined here
  -->   /.cargo/registry/src/index.crates.io-6f17d22bba15001f/sherpa-rs-0.6.2/src/utils.rs:52:8
   |
52 | pub fn cstr_to_string(ptr: *const u8) -> String {
   |        ^^^^^^^^^^^^^^ --------------

error[E0308]: mismatched types
  -->   /.cargo/registry/src/index.crates.io-6f17d22bba15001f/sherpa-rs-0.6.2/src/speaker_id.rs:39:20
   |
39 |             model: model.as_ptr(),
   |                    ^^^^^^^^^^^^^^ expected `*const i8`, found `*const u8`
   |
   = note: expected raw pointer `*const i8`
              found raw pointer `*const u8`

error[E0308]: mismatched types
  -->   /.cargo/registry/src/index.crates.io-6f17d22bba15001f/sherpa-rs-0.6.2/src/speaker_id.rs:41:23
   |
41 |             provider: provider.as_ptr(),
   |                       ^^^^^^^^^^^^^^^^^ expected `*const i8`, found `*const u8`
   |
   = note: expected raw pointer `*const i8`
              found raw pointer `*const u8`

error[E0308]: mismatched types
  -->   /.cargo/registry/src/index.crates.io-6f17d22bba15001f/sherpa-rs-0.6.2/src/vad.rs:54:20
   |
54 |             model: model.as_ptr(),
   |                    ^^^^^^^^^^^^^^ expected `*const i8`, found `*const u8`
   |
   = note: expected raw pointer `*const i8`
              found raw pointer `*const u8`

error[E0308]: mismatched types
  -->   /.cargo/registry/src/index.crates.io-6f17d22bba15001f/sherpa-rs-0.6.2/src/vad.rs:64:23
   |
64 |             provider: provider.as_ptr(),
   |                       ^^^^^^^^^^^^^^^^^ expected `*const i8`, found `*const u8`
   |
   = note: expected raw pointer `*const i8`
              found raw pointer `*const u8`

error[E0308]: mismatched types
  -->   /.cargo/registry/src/index.crates.io-6f17d22bba15001f/sherpa-rs-0.6.2/src/whisper.rs:70:22
   |
70 |             decoder: decoder_ptr.as_ptr(),
   |                      ^^^^^^^^^^^^^^^^^^^^ expected `*const i8`, found `*const u8`
   |
   = note: expected raw pointer `*const i8`
              found raw pointer `*const u8`

error[E0308]: mismatched types
  -->   /.cargo/registry/src/index.crates.io-6f17d22bba15001f/sherpa-rs-0.6.2/src/whisper.rs:71:22
   |
71 |             encoder: encoder_ptr.as_ptr(),
   |                      ^^^^^^^^^^^^^^^^^^^^ expected `*const i8`, found `*const u8`
   |
   = note: expected raw pointer `*const i8`
              found raw pointer `*const u8`

error[E0308]: mismatched types
  -->   /.cargo/registry/src/index.crates.io-6f17d22bba15001f/sherpa-rs-0.6.2/src/whisper.rs:72:23
   |
72 |             language: language_ptr.as_ptr(),
   |                       ^^^^^^^^^^^^^^^^^^^^^ expected `*const i8`, found `*const u8`
   |
   = note: expected raw pointer `*const i8`
              found raw pointer `*const u8`

error[E0308]: mismatched types
  -->   /.cargo/registry/src/index.crates.io-6f17d22bba15001f/sherpa-rs-0.6.2/src/whisper.rs:73:19
   |
73 |             task: task_ptr.as_ptr(),
   |                   ^^^^^^^^^^^^^^^^^ expected `*const i8`, found `*const u8`
   |
   = note: expected raw pointer `*const i8`
              found raw pointer `*const u8`

error[E0308]: mismatched types
  -->   /.cargo/registry/src/index.crates.io-6f17d22bba15001f/sherpa-rs-0.6.2/src/whisper.rs:78:20
   |
78 |             model: sense_voice_model_ptr.as_ptr(),
   |                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `*const i8`, found `*const u8`
   |
   = note: expected raw pointer `*const i8`
              found raw pointer `*const u8`

error[E0308]: mismatched types
  -->   /.cargo/registry/src/index.crates.io-6f17d22bba15001f/sherpa-rs-0.6.2/src/whisper.rs:79:23
   |
79 |             language: sense_voice_language_ptr.as_ptr(),
   |                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `*const i8`, found `*const u8`
   |
   = note: expected raw pointer `*const i8`
              found raw pointer `*const u8`

error[E0308]: mismatched types
  -->   /.cargo/registry/src/index.crates.io-6f17d22bba15001f/sherpa-rs-0.6.2/src/whisper.rs:84:24
   |
84 |             bpe_vocab: bpe_vocab_ptr.as_ptr(),
   |                        ^^^^^^^^^^^^^^^^^^^^^^ expected `*const i8`, found `*const u8`
   |
   = note: expected raw pointer `*const i8`
              found raw pointer `*const u8`

error[E0308]: mismatched types
  -->   /.cargo/registry/src/index.crates.io-6f17d22bba15001f/sherpa-rs-0.6.2/src/whisper.rs:91:23
   |
91 |             provider: provider_ptr.as_ptr(),
   |                       ^^^^^^^^^^^^^^^^^^^^^ expected `*const i8`, found `*const u8`
   |
   = note: expected raw pointer `*const i8`
              found raw pointer `*const u8`

error[E0308]: mismatched types
  -->   /.cargo/registry/src/index.crates.io-6f17d22bba15001f/sherpa-rs-0.6.2/src/whisper.rs:94:21
   |
94 |             tokens: tokens_ptr.as_ptr(),
   |                     ^^^^^^^^^^^^^^^^^^^ expected `*const i8`, found `*const u8`
   |
   = note: expected raw pointer `*const i8`
              found raw pointer `*const u8`

error[E0308]: mismatched types
   -->   /.cargo/registry/src/index.crates.io-6f17d22bba15001f/sherpa-rs-0.6.2/src/whisper.rs:111:30
    |
111 |             decoding_method: decoding_method_ptr.as_ptr(), // greedy_search, modified_beam_search
    |                              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `*const i8`, found `*const u8`
    |
    = note: expected raw pointer `*const i8`
               found raw pointer `*const u8`

error[E0308]: mismatched types
   -->   /.cargo/registry/src/index.crates.io-6f17d22bba15001f/sherpa-rs-0.6.2/src/whisper.rs:150:39
    |
150 |             let text = cstr_to_string(raw_result.text);
    |                        -------------- ^^^^^^^^^^^^^^^ expected `*const u8`, found `*const i8`
    |                        |
    |                        arguments to this function are incorrect
    |
    = note: expected raw pointer `*const u8`
               found raw pointer `*const i8`
note: function defined here
   -->   /.cargo/registry/src/index.crates.io-6f17d22bba15001f/sherpa-rs-0.6.2/src/utils.rs:52:8
    |
52  | pub fn cstr_to_string(ptr: *const u8) -> String {
    |        ^^^^^^^^^^^^^^ --------------

error[E0308]: mismatched types
  -->   /.cargo/registry/src/index.crates.io-6f17d22bba15001f/sherpa-rs-0.6.2/src/zipformer.rs:35:22
   |
35 |             decoder: decoder_ptr.as_ptr(),
   |                      ^^^^^^^^^^^^^^^^^^^^ expected `*const i8`, found `*const u8`
   |
   = note: expected raw pointer `*const i8`
              found raw pointer `*const u8`

error[E0308]: mismatched types
  -->   /.cargo/registry/src/index.crates.io-6f17d22bba15001f/sherpa-rs-0.6.2/src/zipformer.rs:36:22
   |
36 |             encoder: encoder_ptr.as_ptr(),
   |                      ^^^^^^^^^^^^^^^^^^^^ expected `*const i8`, found `*const u8`
   |
   = note: expected raw pointer `*const i8`
              found raw pointer `*const u8`

error[E0308]: mismatched types
  -->   /.cargo/registry/src/index.crates.io-6f17d22bba15001f/sherpa-rs-0.6.2/src/zipformer.rs:37:21
   |
37 |             joiner: joiner_ptr.as_ptr(),
   |                     ^^^^^^^^^^^^^^^^^^^ expected `*const i8`, found `*const u8`
   |
   = note: expected raw pointer `*const i8`
              found raw pointer `*const u8`

error[E0308]: mismatched types
  -->   /.cargo/registry/src/index.crates.io-6f17d22bba15001f/sherpa-rs-0.6.2/src/zipformer.rs:43:23
   |
43 |             provider: provider_ptr.as_ptr(),
   |                       ^^^^^^^^^^^^^^^^^^^^^ expected `*const i8`, found `*const u8`
   |
   = note: expected raw pointer `*const i8`
              found raw pointer `*const u8`

error[E0308]: mismatched types
  -->   /.cargo/registry/src/index.crates.io-6f17d22bba15001f/sherpa-rs-0.6.2/src/zipformer.rs:45:21
   |
45 |             tokens: tokens_ptr.as_ptr(),
   |                     ^^^^^^^^^^^^^^^^^^^ expected `*const i8`, found `*const u8`
   |
   = note: expected raw pointer `*const i8`
              found raw pointer `*const u8`

error[E0308]: mismatched types
  -->   /.cargo/registry/src/index.crates.io-6f17d22bba15001f/sherpa-rs-0.6.2/src/zipformer.rs:77:30
   |
77 |             decoding_method: decoding_method_ptr.as_ptr(),
   |                              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `*const i8`, found `*const u8`
   |
   = note: expected raw pointer `*const i8`
              found raw pointer `*const u8`

error[E0308]: mismatched types
   -->   /.cargo/registry/src/index.crates.io-6f17d22bba15001f/sherpa-rs-0.6.2/src/zipformer.rs:116:39
    |
116 |             let text = cstr_to_string(raw_result.text);
    |                        -------------- ^^^^^^^^^^^^^^^ expected `*const u8`, found `*const i8`
    |                        |
    |                        arguments to this function are incorrect
    |
    = note: expected raw pointer `*const u8`
               found raw pointer `*const i8`
note: function defined here
   -->   /.cargo/registry/src/index.crates.io-6f17d22bba15001f/sherpa-rs-0.6.2/src/utils.rs:52:8
    |
52  | pub fn cstr_to_string(ptr: *const u8) -> String {
    |        ^^^^^^^^^^^^^^ --------------

error[E0308]: mismatched types
  -->   /.cargo/registry/src/index.crates.io-6f17d22bba15001f/sherpa-rs-0.6.2/src/utils.rs:17:16
   |
17 |         Self { ptr }
   |                ^^^ expected `*mut u8`, found `*mut i8`
   |
   = note: expected raw pointer `*mut u8`
              found raw pointer `*mut i8`

error[E0308]: mismatched types
   -->   /.cargo/registry/src/index.crates.io-6f17d22bba15001f/sherpa-rs-0.6.2/src/utils.rs:42:43
    |
42  |                 let _ = CString::from_raw(self.ptr as *mut u8);
    |                         ----------------- ^^^^^^^^^^^^^^^^^^^ expected `*mut i8`, found `*mut u8`
    |                         |
    |                         arguments to this function are incorrect
    |
    = note: expected raw pointer `*mut i8`
               found raw pointer `*mut u8`
note: associated function defined here
   -->   /.rustup/toolchains/stable-aarch64-apple-darwin/lib/rustlib/src/rust/library/alloc/src/ffi/c_str.rs:396:19
    |
396 |     pub unsafe fn from_raw(ptr: *mut c_char) -> CString {
    |                   ^^^^^^^^

error[E0308]: mismatched types
   -->   /.cargo/registry/src/index.crates.io-6f17d22bba15001f/sherpa-rs-0.6.2/src/utils.rs:57:38
    |
57  |             std::ffi::CStr::from_ptr(ptr).to_string_lossy().into_owned()
    |             ------------------------ ^^^ expected `*const i8`, found `*const u8`
    |             |
    |             arguments to this function are incorrect
    |
    = note: expected raw pointer `*const i8`
               found raw pointer `*const u8`
note: associated function defined here
   -->   /.rustup/toolchains/stable-aarch64-apple-darwin/lib/rustlib/src/rust/library/core/src/ffi/c_str.rs:278:25
    |
278 |     pub const unsafe fn from_ptr<'a>(ptr: *const c_char) -> &'a CStr {
    |                         ^^^^^^^^

error[E0308]: mismatched types
  -->   /.cargo/registry/src/index.crates.io-6f17d22bba15001f/sherpa-rs-0.6.2/src/tts.rs:78:31
   |
78 |                     data_dir: data_dir.as_ptr(),
   |                               ^^^^^^^^^^^^^^^^^ expected `*const i8`, found `*const u8`
   |
   = note: expected raw pointer `*const i8`
              found raw pointer `*const u8`

error[E0308]: mismatched types
  -->   /.cargo/registry/src/index.crates.io-6f17d22bba15001f/sherpa-rs-0.6.2/src/tts.rs:79:31
   |
79 |                     dict_dir: dict_dir.as_ptr(),
   |                               ^^^^^^^^^^^^^^^^^ expected `*const i8`, found `*const u8`
   |
   = note: expected raw pointer `*const i8`
              found raw pointer `*const u8`

error[E0308]: mismatched types
  -->   /.cargo/registry/src/index.crates.io-6f17d22bba15001f/sherpa-rs-0.6.2/src/tts.rs:81:30
   |
81 |                     lexicon: lexicon.as_ptr(),
   |                              ^^^^^^^^^^^^^^^^ expected `*const i8`, found `*const u8`
   |
   = note: expected raw pointer `*const i8`
              found raw pointer `*const u8`

error[E0308]: mismatched types
  -->   /.cargo/registry/src/index.crates.io-6f17d22bba15001f/sherpa-rs-0.6.2/src/tts.rs:82:28
   |
82 |                     model: model.as_ptr(),
   |                            ^^^^^^^^^^^^^^ expected `*const i8`, found `*const u8`
   |
   = note: expected raw pointer `*const i8`
              found raw pointer `*const u8`

error[E0308]: mismatched types
  -->   /.cargo/registry/src/index.crates.io-6f17d22bba15001f/sherpa-rs-0.6.2/src/tts.rs:85:29
   |
85 |                     tokens: tokens.as_ptr(),
   |                             ^^^^^^^^^^^^^^^ expected `*const i8`, found `*const u8`
   |
   = note: expected raw pointer `*const i8`
              found raw pointer `*const u8`

error[E0308]: mismatched types
  -->   /.cargo/registry/src/index.crates.io-6f17d22bba15001f/sherpa-rs-0.6.2/src/tts.rs:89:27
   |
89 |                 provider: provider.as_ptr(),
   |                           ^^^^^^^^^^^^^^^^^ expected `*const i8`, found `*const u8`
   |
   = note: expected raw pointer `*const i8`
              found raw pointer `*const u8`

error[E0308]: mismatched types
  -->   /.cargo/registry/src/index.crates.io-6f17d22bba15001f/sherpa-rs-0.6.2/src/tts.rs:91:24
   |
91 |             rule_fars: rule_fars.as_ptr(),
   |                        ^^^^^^^^^^^^^^^^^^ expected `*const i8`, found `*const u8`
   |
   = note: expected raw pointer `*const i8`
              found raw pointer `*const u8`

error[E0308]: mismatched types
  -->   /.cargo/registry/src/index.crates.io-6f17d22bba15001f/sherpa-rs-0.6.2/src/tts.rs:92:24
   |
92 |             rule_fsts: rule_fsts.as_ptr(),
   |                        ^^^^^^^^^^^^^^^^^^ expected `*const i8`, found `*const u8`
   |
   = note: expected raw pointer `*const i8`
              found raw pointer `*const u8`

error[E0308]: mismatched types
    -->   /.cargo/registry/src/index.crates.io-6f17d22bba15001f/sherpa-rs-0.6.2/src/tts.rs:103:71
     |
103  |                 sherpa_rs_sys::SherpaOnnxOfflineTtsGenerate(self.tts, text.as_ptr(), sid, speed);
     |                 -------------------------------------------           ^^^^^^^^^^^^^ expected `*const i8`, found `*const u8`
     |                 |
     |                 arguments to this function are incorrect
     |
     = note: expected raw pointer `*const i8`
                found raw pointer `*const u8`
note: function defined here
    -->     /src-tauri/target/i686-linux-android/release/build/sherpa-rs-sys-9a3b1ba71534b6f6/out/bindings.rs:2697:12
     |
2697 |     pub fn SherpaOnnxOfflineTtsGenerate(
     |            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:rustBuildX86Release'.
> Process 'command 'pnpm'' finished with non-zero exit value 1

BUILD FAILED in 22s
@oddpxl oddpxl added the bug Something isn't working label Jan 14, 2025
@vlovich
Copy link
Contributor

vlovich commented Jan 19, 2025

Reading through the codebase, I think there's a lot of potentially unnecessary extra complexity here. Instead of trying to manage what the native integer type is, why not use std::ffi::c_char which maps to whatever is platform appropriate & then you can get rid of all the i8/u8 platform-specific mappings.

@thewh1teagle
Copy link
Owner

Thanks @vlovich

I created #78

Do you know if I can simplify the way I pass and free strings from Rust to C as well? -

impl RawCStr {
/// Creates a new `CStr` from a given Rust string slice.
pub fn new(s: &str) -> Self {
let cstr = CString::new(s).expect("CString::new failed");
let ptr = cstr.into_raw();
Self { ptr }
}
/// Returns the raw pointer to the internal C string.
///
/// # Safety
/// This function only returns the raw pointer and does not transfer ownership.
/// The pointer remains valid as long as the `CStr` instance exists.
/// Be cautious not to deallocate or modify the pointer after using `CStr::new`.
#[cfg(target_os = "android")]
pub fn as_ptr(&self) -> *const u8 {
self.ptr as *const u8
}
#[cfg(not(target_os = "android"))]
pub fn as_ptr(&self) -> *const i8 {
self.ptr
}
}
impl Drop for RawCStr {
fn drop(&mut self) {
if !self.ptr.is_null() {
unsafe {
#[cfg(target_os = "android")]
let _ = CString::from_raw(self.ptr as *mut u8);
#[cfg(not(target_os = "android"))]
let _ = CString::from_raw(self.ptr);
}
}
}
}

Here I store them in variable so they won't free until the end of the scope

let tts = unsafe {
let model = RawCStr::new(&config.model);
let voices = RawCStr::new(&config.voices);
let tokens = RawCStr::new(&config.tokens);
let data_dir = RawCStr::new(&config.data_dir);

@thewh1teagle
Copy link
Owner

@oddpxl

I released new version, if the issue persists feel free to reopen the issue

@vlovich
Copy link
Contributor

vlovich commented Jan 19, 2025

@thewh1teagle if I'm not mistaken, the RawCString class isn't really doing anything extra on top of CString and call .as_ptr to retrieve the pointer. So I think you could just get rid of RawCString use CString directly rather than leaking/restoring ownership.

On an unrelated note, I wanted to point out that the recognizer API takes in an owned Vec but that implies you need far more ownership than you need since the Sherpa API only uses the contents for the duration of the transcribe API and not any longer. When ownership of something is contained within a function call, it's a better practice to accept a reference to the most generic type that meets your needs. In this case it would be &[f32] since you only need a slice of audio samples regardless of how externally they're stored (similar to how you'd accept a &str instead of String/&String if the string's lifetime is only needed for the duration of the function)

@oddpxl
Copy link
Author

oddpxl commented Jan 19, 2025

[@oddpxl]
I released new version, if the issue persists feel free to reopen the issue

pnpm tauri android dev and build now works ! yay !

..however my app crashes - and after some adb logcat squinting I find ...

"AndroidRuntime: java.lang.UnsatisfiedLinkError: dlopen failed: library "libsherpa-onnx-c-api.so" not found: needed by /data/app/~~tBCrXNhgm4UdkNwlHficCw==/com.odd.dev-zmNYNjfdO8zF-zKo3_ujGA==/base.apk!/lib/arm64-v8a/libtauri_mobile_neo_lib.so in namespace clns-7 "

Not sure if I did something wrong in my setup - but it seems it can't find libsherpa-onnx-c-api.so

I can see there's a link...
/src-tauri/gen/android/app/src/main/jniLibs/arm64-v8a/libtauri_mobile_neo_lib.so

..that leads to...
/src-tauri/target/aarch64-linux-android/release/libtauri_mobile_neo_lib.so

So it looks like all should be fine ?

Yet logcat says it can't find the file when running the app ( dev and build )

Any ideas ?

Opened the issue here --> #79

@thewh1teagle
Copy link
Owner

if I'm not mistaken, the RawCString class isn't really doing anything extra on top of CString and call .as_ptr to retrieve the pointer. So I think you could just get rid of RawCString use CString directly rather than leaking/restoring ownership.

I created it to centeralize the logic of how actually get the pointer for the cstring and drop it, with potential to improve it in one place.

On an unrelated note, I wanted to point out that the recognizer API takes in an owned Vec but that implies you need far more ownership than you need since the Sherpa API only uses the contents for the duration of the transcribe API and not any longer. When ownership of something is contained within a function call, it's a better practice to accept a reference to the most generic type that meets your needs. In this case it would be &[f32] since you only need a slice of audio samples regardless of how externally they're stored (similar to how you'd accept a &str instead of String/&String if the string's lifetime is only needed for the duration of the function)

Can you show me which recognizer you reffered to?

@thewh1teagle
Copy link
Owner

Not sure if I did something wrong in my setup - but it seems it can't find libsherpa-onnx-c-api.so

"aarch64-linux-android": [
"jniLibs/arm64-v8a/libsherpa-onnx-c-api.so",
"jniLibs/arm64-v8a/libonnxruntime.so"
],

You need to make sure that these shared libraries available in runtime in the Android. usually you need to place them in the Android JniLibs/ (Google/LLM it)

@oddpxl
Copy link
Author

oddpxl commented Jan 19, 2025

YES !

App no longer crashes !

There's only a symlink for for libtauri_mobile_neo_lib.so ( not the other two ) in
/src-tauri/gen/android/app/src/main/jniLibs/arm64-v8a
/src-tauri/gen/android/app/src/main/jniLibs/arm64-v7a

so I copied
libonnxruntime.so
libsherpa-onnx-c-api.so

from
/src-tauri/target/aarch64-linux-android/release/
/src-tauri/target/armv7-linux-androideabi/release/

to
/src-tauri/gen/android/app/src/main/jniLibs/arm64-v8a
/src-tauri/gen/android/app/src/main/jniLibs/arm64-v7a

..and now it works.

That said - my VAD no longer initialise... ..so perhaps some VAD bundling problem ( on my side ) - looking at that now.

@vlovich
Copy link
Contributor

vlovich commented Jan 20, 2025

I created it to centeralize the logic of how actually get the pointer for the cstring and drop it, with potential to improve it in one place.

I get that. I'm just highlighting that CString already does that. It's possible you're planning additional capabilities for the class, just saying right now it's identical to CString with no extra functionality unless I'm misreading the code.

Re the recognizer, I was working with the whisper recognizer.

@thewh1teagle
Copy link
Owner

I get that. I'm just highlighting that CString already does that. It's possible you're planning additional capabilities for the class, just saying right now it's identical to CString with no extra functionality unless I'm misreading the code.

Yes currently that's all it does
The thing is that the only reason that pointer remain valid and freed only after sherpa used it, is the fact that I hold it in variable and it's dropped in the end of the scope
If I would create and pass it directly there was undefined behavior (I think it's freed immediately)
So that's a bit risky in Rust and weird way to make sure it's freed only in the end of the scope

@vlovich
Copy link
Contributor

vlovich commented Jan 20, 2025

CString is literally that - when the reference drops the memory is freed. Are you perhaps confusing it with CStr which is like str?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants