Coder Social home page Coder Social logo

Comments (40)

atykhonov avatar atykhonov commented on August 17, 2024

Thank you very much for that issue report (and overall for that idea)!
Will be busy with that as soon as possible.

from google-translate.

atykhonov avatar atykhonov commented on August 17, 2024

Hi!

I would like to ask: which OS do you use?
For linux I already implemented listening feature and I'm ready to deploy but if you use windows it is still require more attention.

from google-translate.

llcc avatar llcc commented on August 17, 2024

That is wonderful! Great!

However I am sorry to tell you that I am on windows 7.

Many thanks for your effort!

from google-translate.

atykhonov avatar atykhonov commented on August 17, 2024

Hi! You are welcome!

I just finished functionality to listen translations (was too busy last month so, sorry, with some lateness). And it seems works fine. I hope it will be smoothly workable for you as well. Look forward for your feedback.

To try it out of course you should update your current google-translate to the latest version 0.9.0. By default listen translation functionality is disabled. You need define google-translate-listen-program first. You need to put there full path to the program which can play audio (actually mpeg files). For example (for Windows):

(setq google-translate-listen-program "C:\\mplayer\\mplayer.exe")

I tried only one program: mplayer. So I suggest you to use the same. I downloaded mplayer from that page: http://mplayerwin.sourceforge.net/downloads.html and I've tested listen functionality with that.

Please try and let me know whether everything works as you expected.

I look forward to hearing from you.

from google-translate.

atykhonov avatar atykhonov commented on August 17, 2024

P. S. In case of other program (than mplayer) supposedly it will be required to change a little bit functionality (depends on arguments which that program accepts). I didn't provide functionality for all possible cases, just for one case. But anyway, just let me know if something will be wrong with current version.

Thanks!

from google-translate.

llcc avatar llcc commented on August 17, 2024

Hi, that is awesome!

I tried what you offered.
I set up the command like (setq google-translate-listen-program "~/mplayer/mplayer.exe") and got:
image, and no voice outputted.

then I clicked the listen, still no voice produced.

Then i changed the program path to C:\\Users\\admin\\GoogleDrive\\Git\\Configurations\\Emacs\\mplayer\\mplayer.exe, still no luck to output the voice.

Then i checked the mplayer with a .mp3, firstly it scanned my windows fonts and finally outputted the voice.

Best regards!

from google-translate.

alezost avatar alezost commented on August 17, 2024

Thanks Andrey, that's a great feature.
I think it would be good to enable it by default, like this:

(defcustom google-translate-listen-program (executable-find "mplayer")
  ...)

from google-translate.

atykhonov avatar atykhonov commented on August 17, 2024

@llcc , @alezost thank you very much guys for your feedbacks and help!

@alezost thank you for the great trick! I enabled mplayer by default as you suggested and it seems works fine for me. How about you? Do you use Windows?

@llcc could you please download the latest version (0.9.1, I just pushed the last changes) and try with them? Also, did you download exactly the same mplayer as I mentioned? I tried another and it behaves in the same manner as yours and didn't work at all. The one for which I put url works fine for me.

You can check your mplayer with the following command via cmd:

mplayer.exe "http://translate.google.com/translate_tts?ie=UTF-8&q=book&tl=en&total=1&idx=0&textlen=4&client=t&prev=input"

It should output the audio for word book without any issues and right after execution (may be with very short delay).

Before test in Emacs make sure that mplayer is located somewhere in the PATH. Add the path to the mplayer (its directory C:\Users\admin\GoogleDrive\Git\Configurations\Emacs\mplayer\) to the system variable PATH. In such case you don't have to define (setq google-translate-listen-program "~/mplayer/mplayer.exe").

from google-translate.

llcc avatar llcc commented on August 17, 2024

@atykhonov

It is really strange that why the listening program does not work in my windows.

I tried many times, still no lucky for me.

I add the mplayer path to system path and then call mplayer in comandline that works with audio outputted. However, I never made it in emacs.

I deleted and reinstalled google-translate for two or three times. It seems like that google-translate sets listening program automatically like:

image

It is really strange....

from google-translate.

alezost avatar alezost commented on August 17, 2024

@atykhonov, Yeah it works for me (I'm using GNU/Linux distribution).

@llcc, As far as I understand mplayer works for you in cmd.exe, but not in Emacs.
If so, try to test mplayer in emacs by evaluating the following code:

(let ((buf "*mplayer output*"))
  (with-current-buffer (get-buffer-create buf)
    (call-process "/path/to/mplayer.exe" nil t nil "-quiet" "-endpos" "10" "/path/to/my-favourite-song.mp3")
    (switch-to-buffer buf)))

It should play 10 seconds of the file (the last argument in the call-process should be a real path to some playable audio-file in your system) and then switch you to the buffer with the output of mplayer.
If there was no sound, paste that output here, so we could think about the problem.
If it works, replace the path to the file with the link Andrey provided above (to the book word), and try again.

P.S. (Just in case) You can evaluate the code, for example, by inserting it into the *scratch* buffer and pressing C-x C-e when your cursor is placed right after the last closing parenthesis.

from google-translate.

atykhonov avatar atykhonov commented on August 17, 2024

I deleted and reinstalled google-translate for two or three times. It seems like that google-translate sets listening program automatically like

Yes, that's right, it sets automatically. Emacs looks for mplayer.exe in the directories listed in the PATH, and if Emacs finds then sets the full path to the mplayer.exe. This functionality was added with last change, thanks to @alezost !

And if the path really sets, and it really sets as you confirmed, then Emacs really finds the mplayer.exe and can use it. Why audio doesn't output? If it works from command line, then try to test as @alezost suggested. And provide us as many info as you can, it would really help us to realize what issue exist and how it could be resolved.

Despite of the fact that it sets automatically you can set any other program for example:
(setq google-translate-listen-program "C:/vlc/vlc.exe"). This is just for example and just highlights idea that current translation listening functionality will use google-translate-listen-program to listen audio in the following way (tt calls the program like we tried from command line): mplayer.exe <http_path_to_the_audio>. (by the way for me vlc doesn't work in Emacs, it works well from command line but not for google translation, year need more time to figure out what is the issue).

But... With mplayer.exe it should work... I tested it under Windows and works fine for me. It would be much appreciated if you'll provide more info, for example the output of code execution which @alezost provided. As far as I undertand it works well for you from command line (cmd.exe) then there could be some issue with the execution from Emacs.

from google-translate.

llcc avatar llcc commented on August 17, 2024

@alezost Thanks for your evaluation code.
Emacs works well by that evaluation with producing output of .mp3 file and book, though still no luck for listening in google-translation. It is getting stranger and stranger..

@atykhonov As described above, still no luck. Emacs works well with mplayer but that listening button.

from google-translate.

atykhonov avatar atykhonov commented on August 17, 2024

Could you please to try the following pieces of codes:

(let ((buf "*mplayer output*"))
  (with-current-buffer (get-buffer-create buf)
    (call-process "/path/to/mplayer.exe" nil t nil "-quiet" "http://translate.google.com/translate_tts?ie=UTF-8&q=book&tl=en&total=1&idx=0&textlen=4&client=t&prev=input")
    (switch-to-buffer buf)))
(let ((buf "*mplayer output*"))
  (with-current-buffer (get-buffer-create buf)
    (call-process "/path/to/mplayer.exe" nil t nil "http://translate.google.com/translate_tts?ie=UTF-8&q=book&tl=en&total=1&idx=0&textlen=4&client=t&prev=input")
    (switch-to-buffer buf)))
(let ((buf "*mplayer output*"))
  (with-current-buffer (get-buffer-create buf)
    (call-process (executable-find "mplayer") nil t nil "http://translate.google.com/translate_tts?ie=UTF-8&q=book&tl=en&total=1&idx=0&textlen=4&client=t&prev=input")
    (switch-to-buffer buf)))
(let ((buf "*mplayer output*"))
  (with-current-buffer (get-buffer-create buf)
    (call-process (executable-find "mplayer") nil t nil "-quiet" "http://translate.google.com/translate_tts?ie=UTF-8&q=book&tl=en&total=1&idx=0&textlen=4&client=t&prev=input")
    (switch-to-buffer buf)))

How they does work for you? Which of them works for you which not?

from google-translate.

atykhonov avatar atykhonov commented on August 17, 2024

@llcc and... hm... a little bit strange question but anyway: do you click on the button by mouse or hit the Return? Could you please try both ways?

from google-translate.

atykhonov avatar atykhonov commented on August 17, 2024

@alezost does it work for you on mouse click?

from google-translate.

atykhonov avatar atykhonov commented on August 17, 2024

I'm just surprised that it doesn't work on mouse left click but on mouse middle click. I can say that I've never used the mouse with Emacs so I'm pretty confused right now. By default clickable text (buttons) such as [Listen] button is bound to [mouse-2] which is middle click...

from google-translate.

alezost avatar alezost commented on August 17, 2024

Oh, with mouse click it didn't work indeed (I didn't even think about trying the mouse).
I think that's because there is no follow-link property in that button.
@atykhonov, try to add that property at https://github.com/atykhonov/google-translate/blob/master/google-translate-core-ui.el#L365-368:

    (insert-text-button "[Listen]"
                        'action 'google-translate--listen-action
                        'text text
                        'follow-link t
                        'language language)

I'm not sure, but it should probably work (look at (info "(elisp) Clickable Text")).

from google-translate.

atykhonov avatar atykhonov commented on August 17, 2024

@alezost thank you a lot!

With follow-link now it works fine for me.

I hope for you @llcc it works as well, please try to hit Return on Listen button. If that will output the audio then download the latest google-translate sources and you'll be able to use left mouse click as well.

I look forward to hearing from you.

from google-translate.

llcc avatar llcc commented on August 17, 2024

@atykhonov @alezost I am sorry to reply late.

I tried left click and white-space before just not tried middle-click and return, sorry!

I tested the four blocks and they all works.

Now when i hit the listen button by return, it shows a message "Retrieving audio message". However, it just lasts and no audio produced.
I seems like close to the final success with some slight alteration. Thanks very much for your guys' help!

from google-translate.

alezost avatar alezost commented on August 17, 2024

@llcc Hm, that's strange. Are you sure that google-translate-listen-program is set to the right path now?
Try the following:

(let ((buf "*mplayer output*"))
  (with-current-buffer (get-buffer-create buf)
    (call-process google-translate-listen-program nil t nil "-quiet" "http://translate.google.com/translate_tts?ie=UTF-8&q=book&tl=en&total=1&idx=0&textlen=4&client=t&prev=input")
    (switch-to-buffer buf)))

And thank you for the patient reporting.

from google-translate.

llcc avatar llcc commented on August 17, 2024

@alezost It works, and I am sure the 'google-translate-listen-program' path is right because I just copied it from customizing options and replaced the related path with it in your codes.

from google-translate.

atykhonov avatar atykhonov commented on August 17, 2024

@alezost really strange... Still looking for a reason which can cause such an issue...

@llcc , what does output the following:

(let ((buf "*mplayer output*"))
  (with-current-buffer (get-buffer-create buf)
    (call-process google-translate-listen-program nil t nil "http://translate.google.com/translate_tts?ie=UTF-8&q=book&tl=en&total=1&idx=0&textlen=4&client=t&prev=input")
    (switch-to-buffer buf)))

Please note: I removed "-quiet".
Please paste the output here.

from google-translate.

llcc avatar llcc commented on August 17, 2024

Hi @atykhonov , this is the output, it also works.

MPlayer Redxii-SVN-r37205-4.8.2 (i686) (C) 2000-2014 MPlayer Team

Compiled against FFmpeg version N-63282-g4a30f08

Build date: Mon May 19 06:10:15 EDT 2014

getch2: 6 can't get number of input events  [disabling console input]



Playing http://translate.google.com/translate_tts?ie=UTF-8&q=book&tl=en&total=1&idx=0&textlen=4&client=t&prev=input.

Resolving translate.google.com for AF_INET...

Connecting to server translate.google.com[74.125.235.206]: 80...



Cache size set to 320 KBytes


Cache fill:  0.00% (0 bytes)   
Cache fill:  0.75% (2448 bytes)   



Audio only file format detected.

Load subtitles in http://translate.google.com/

Load subtitles in C:\Users\admin\GoogleDrive\Git\Configurations\Emacs/mplayer/sub/

==========================================================================

Opening audio decoder: [mpg123] MPEG 1.0/2.0/2.5 layers I, II, III

AUDIO: 16000 Hz, 2 ch, s16le, 32.0 kbit/6.25% (ratio: 4000->64000)

Selected audio codec: [mpg123] afm: mpg123 (MPEG 1.0/2.0/2.5 layers I, II, III)

==========================================================================

AO: [dsound] 16000Hz 2ch s16le (2 bytes per sample)

Video: no video

Starting playback...

A:  -0.0 (unknown) of 0.6 (00.6)  0.0% 0%                                      
A:  -0.0 (unknown) of 0.6 (00.6)  0.0% 0%                                      






Exiting... (End of file)

from google-translate.

atykhonov avatar atykhonov commented on August 17, 2024

Ok!

I just pushed to the repository functionality which will allow to get debug info for translation listening. That I hope will be helpful. Please checkout (you need only the latest google-translate-core-ui.el if that make a sense). Then:

(setq google-translate-translation-listening-debug t)

After you'll hit Listen button it should create *mplayer output* buffer with the output from mplayer, in the same manner as these piece of code which you recently tested. Please paste that output here again.

from google-translate.

llcc avatar llcc commented on August 17, 2024

Hi, @atykhonov There are really some problems here, The output is:

Listen program: c:/Users/admin/GoogleDrive/Git/Configurations/Emacs/mplayer/mplayer.exe

Listen URL: http://translate.google.com/translate_tts?ie=UTF-8&q=translate&tl=cn&total=1&idx=0&textlen=9&client=t&prev=input

MPlayer Redxii-SVN-r37205-4.8.2 (i686) (C) 2000-2014 MPlayer Team

Compiled against FFmpeg version N-63282-g4a30f08

Build date: Mon May 19 06:10:15 EDT 2014

getch2: 6 can't get number of input events  [disabling console input]



Playing http://translate.google.com/translate_tts?ie=UTF-8&q=translate&tl=cn&total=1&idx=0&textlen=9&client=t&prev=input.

Resolving translate.google.com for AF_INET...

Connecting to server translate.google.com[74.125.235.192]: 80...



Server returned 404: Not Found

STREAM_ASF, URL: http://translate.google.com/translate_tts?ie=UTF-8&q=translate&tl=cn&total=1&idx=0&textlen=9&client=t&prev=input

Resolving translate.google.com for AF_INET...

Connecting to server translate.google.com[74.125.235.192]: 80...



Server returned 404:Not Found

Failed to parse header.

Failed, exiting.

Resolving translate.google.com for AF_INET...

Connecting to server translate.google.com[74.125.235.192]: 80...



Server returned 404: Not Found

No stream found to handle url http://translate.google.com/translate_tts?ie=UTF-8&q=translate&tl=cn&total=1&idx=0&textlen=9&client=t&prev=input





Exiting... (End of file)


from google-translate.

alezost avatar alezost commented on August 17, 2024

@llcc, but that's Chinese, try English.
@atykhonov, URLs to Chinese sounds are probably defined differently.

from google-translate.

atykhonov avatar atykhonov commented on August 17, 2024

@alezost hmm... will investigate that case of course...
@llcc please

  • confirm that for English works well (it should)
  • provide the following info for the recent (Chinese) translation:
  • source language
  • target language
  • and please exact text.
    That will allow me to try exactly the same case as you try.

And I'll continue investigation.

from google-translate.

llcc avatar llcc commented on August 17, 2024

@atykhonov that works well.

I think it is the reason that cause the problems. I use the setting below:

(setq google-translate-default-source-language "cn")
(setq google-translate-default-target-language "ja")

It seems like that the post to google translate has a little mistake.

from google-translate.

atykhonov avatar atykhonov commented on August 17, 2024

Ok, thank you! I will investigate that case as soon as possible. Not sure that I'll be able to handle today, but I'll do my best. Stay tuned!

from google-translate.

llcc avatar llcc commented on August 17, 2024

Hi, thanks you very much. Really appreciate!!!

from google-translate.

alezost avatar alezost commented on August 17, 2024

@llcc, I think it should be "zh-CN", not "cn".

from google-translate.

llcc avatar llcc commented on August 17, 2024

@alezost That trick helped! Now the nil problem is corrected.
image

Thanks!

from google-translate.

atykhonov avatar atykhonov commented on August 17, 2024

@llcc And now Listen works fine, right?

from google-translate.

llcc avatar llcc commented on August 17, 2024

@atykhonov Yes, it works perfect.

from google-translate.

alezost avatar alezost commented on August 17, 2024

@llcc I just looked at google-translate-supported-languages-alist. There are two Chinese:

  • "Chinese Simplified" – "zh-CN"
  • "Chinese Traditional" – "zh-TW"

from google-translate.

llcc avatar llcc commented on August 17, 2024

@alezost yes, and there is much difference between the two Chinese in writing.

from google-translate.

atykhonov avatar atykhonov commented on August 17, 2024

@llcc Great!!! I'm really glad!

from google-translate.

atykhonov avatar atykhonov commented on August 17, 2024

Thanks to you guys, three issues was fixed during that discussion! google-translate was improved! Thank you guys very much for your help, much appreciate!

from google-translate.

alezost avatar alezost commented on August 17, 2024

Ok, thanks all, that was a good collaboration. I think this issue can be closed now.

from google-translate.

llcc avatar llcc commented on August 17, 2024

@atykhonov Thanks a million for giving us such a awesome feature to emacs, and for helping me solved various tough problems.

also @alezost many thanks to you for your great help.

You two great men, best wishes.

from google-translate.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.