niedev / RTranslator

Open source real-time translation app for Android that runs locally
Apache License 2.0
6.85k stars 518 forks source link

[BUG] When translating, the translation result will keep adding text. #81

Open codeAndxv opened 1 month ago

codeAndxv commented 1 month ago

Thank you for wanting to report a bug! But before starting, ensure to check if this bug report respects the following requirements:

Describe the bug When I type "你好啊世界如何看待目前的经济局势失业很严重大家都找不到工作未来会变的好吗", it is translated from Chinese to English. The translation results will always append text, just like the one I took in the screenshot. I'm using the latest v2.0.0 commit code ,6bf51c1e2f70

Screenshots

Image 1 Image 3 Image 2

Smartphone (please complete the following information):

Additional context Add any other context about the problem here.

niedev commented 1 month ago

Thank you for reporting this bug, I will investigate on this.

codeAndxv commented 1 month ago

Thank you for reporting this bug, I will investigate on this.

Hi, is this problem difficult to solve, and can you estimate how long it will take to resolve it? Because this issue occurs frequently, it's quite troublesome for me. Thanks! By the way, if you need help, I know some Java and Android.

niedev commented 1 month ago

I did some testing and the problem seems to be due to the quantization of the models (and greater for Chinese), which would make it quite difficult to solve. However I tried adding a period at the end of the sentence that gave you problems and in that case the problem goes away. For now you could try to always add a period at the end of input sentences, let me know if this solves or reduces the problem, in that case I will make an update in which the app will automatically add a period at the end of sentences when needed.

Thanks again.

codeAndxv commented 4 weeks ago

In addition to adding a full stop at the end, and forcibly breaking the entered text.

I tried to add the java code snapper below in this place. Without modifying the model, this problem can be solved.

if (j > 2 * input.getInputIDs().length) {
      android.util.Log.i("decoder", "Reach max tokenId count: " + 2 * input.getInputIDs().length + ", maybe occur error, break while.");
      break;
}

But the root cause is a model problem.

niedev commented 4 weeks ago

@codeAndxv Thank you for your input, this would definitely help. I'll try this change and others next week (I started a new job so I don't have much time, but I should be able to get around to it).

niedev commented 3 weeks ago

The new release that should mitigate this problem is out 🚀, let me know if the problem occurs less.

codeAndxv commented 3 weeks ago

It look fine, Thanks.

zhl111 commented 2 weeks ago

SmartSelect_20241103_173748_RTranslator After I said one sentence, everything turned gray and nothing clicked except the return key.

niedev commented 2 weeks ago

@zhl111 have you tried RTranslator 2.1.2?

zhl111 commented 2 weeks ago

Yes, this is the version I use. My mobile phone is Samsung s23ultra, is it related to the system of the mobile phone?

niedev commented 2 weeks ago

@zhl111 Ok, I don't think this is due to the system of the phone, but it can be due to the tts you use. Everything turn gray (and stay gray) after the transcription appear or before? And if you turn off the TTS (from the top right speaker button in the WalkieTalkie mode) the problem goes away?

zhl111 commented 2 weeks ago

It's all right

niedev commented 2 weeks ago

@zhl111 what tts are you using?

zhl111 commented 2 weeks ago

google tts

niedev commented 2 weeks ago

@zhl111 That's strange, when everything turn gray, it stay gray forever or it return green after the sentence is spoken?

zhl111 commented 2 weeks ago

Before, all the buttons were gray, now they turn green after the sentence is finished

niedev commented 2 weeks ago

@zhl111 Ok, before the bug we discussed was the problem, now the app behaves normally. In WalkieTalkie mode while the app processes the translation and the tts speaks the microphone deactivates because otherwise, the app would recognize the audio of the tts, translating in a loop (the Conversation mode instead, using Bluetooth headphones, never interrupts the microphones because with headphones you obviously don't have this problem).