limura / CaptionSpeaker

CaptionSpeaker は youtube で表示される字幕を発話させる事で耳から聞くことができるようにする chrome extension です。
MIT License
41 stars 18 forks source link

Great plugin but Instability with long videos #14

Closed jeanviet closed 6 months ago

jeanviet commented 6 months ago

Hello,

great plugin, great idea

I used your plugin to vocalize this russian 2 hour long video in french : https://youtu.be/Y3tqLF5zgfw?si=KU_O3GIrCIMPEFue

there is french subtiles, it worked but not the first time.

I have to relaunch chrome several times, switch to french short videos

and now I’m not able to vocalize the video with your plugin

I m using the last Chrome version on Mac OS, Mac Mini M1

is there some kinds of quick hacks to stabilize your plugin on long videos ? I’m not the only one in France to have instabilities with it on foreign videos

maybe troubles with our french chars

I reviewed it here on my YouTube channel : https://youtu.be/Muw-NZmTelU?si=RBxF31mU16JIiKOI

Best regards,

Jean-Baptiste

limura commented 6 months ago

Hello.

Thank you for your service.

I am reading through the machine translation and I think I am not interpreting it correctly, I think it would be easier to translate if you shorten one sentence and write only the main points. Are you saying that the speech is not working correctly while watching the 2 hour video ( https://youtu.be/Y3tqLF5zgfw?si=KU_O3GIrCIMPEFue )? It appears to be working correctly when I have the speech in Japanese on my Windows 11 Chrome at hand. However, I have not confirmed the operation by watching the entire 2-hour video.

Can you explain the following points?

What happened? What is the problem? What I originally wanted to happen What are the steps to take to confirm the problem?

CaptionSpeaker also re-reads the subtitles "when the tab content is switched". It takes some time to read the subtitles. Therefore, speech may not be spoken immediately after the tab is opened. In addition, if the reading of subtitles fails, the speech will not be made. Therefore, if the speech is not spoken, you may want to reload the tab to prompt the subtitles to be reloaded.

This text was translated using DeepL. The original Japanese is shown below.

Translated with DeepL.com (free version)

こんにちは。

お使いいただきありがとうございます。

私は機械翻訳越しで読んでいるので正しく解釈できていないと思います。1文を短くし、要点のみを書く形にすると翻訳しやすくなると思います。 2時間の動画( https://youtu.be/Y3tqLF5zgfw?si=KU_O3GIrCIMPEFue ) の視聴中に発話が正しく動作していないという事ですか? 私が手元の Windows 11 の Chrome で、日本語で発話させた時には正しく動作しているように見えています。ただし、私は2時間の動画を全て観て動作を確認はしていません。

あなたは以下の点に注意して説明できますか?

・何が起こったのか ・何が問題なのか ・本来はどうなって欲しかったのか ・問題点を確認するための操作手順

また、CaptionSpeakerは「タブの内容が切り替わった時」に字幕を読み直します。字幕の読み込みには幾分かの時間がかかります。そのため、タブを開いてからすぐには発話はされない可能性があります。また、字幕の読み込みに失敗している場合は発話されません。そのため、発話がされない場合は字幕の再読み込みを促すためにタブを再読み込みすると良いかもしれません。

この文章はDeepLを用いて翻訳されました。以下に原文の日本語を示します。

jeanviet commented 6 months ago

Thanks Limoura for your quick answer. I made a video to explain in details the instability of your plugin on long videos. I speak in French, you have french subtitles, english, and japanese, translated by ChatGPT.

https://www.youtube.com/watch?v=-n0STFZZ-ts

In the video, I demonstrate that French subtitles work well on a short video but encounter problems with longer foreign language videos. Despite activating subtitles and trying various methods, including refreshing the page, I experience instability and occasional success. I mention the plugin's instability and express a desire for stable subtitles in all situations, particularly for automatic translation from foreign languages to French. I seek advice on ensuring consistent functionality with the plugin and express frustration with its current unreliability.

limura commented 6 months ago

Thank you for your explanation on the movement.

We have checked and found that there are cases where subtitles cannot be read when reading subtitle data.

Specifically, there is a problem with subtitle data retrieved using the following URL https://www.youtube.com/api/timedtext?v=Y3tqLF5zgfw&ei=aEsJZreROoqcvcAPmJ282AI&caps=asr&opi=112496729&xoaf=5&hl=ja&ip=0.0.0.0& ipbits=0&expire=1711910361&sparams=ip%2Cipbits%2Cexpire%2Cv%2Cei%2Ccaps%2Ccaps%2Copi%2Cxoaf&signature=148018676E1CF8A9F31DD8F59F5CA3F5BA7 EBF3E.106997E4D11FA315CC5863D1848C7067F76254B7&key=yt8&lang=fr-FR&fmt=json3&xorb=2&xobt=3&xovt=3&tlang=en&cbr=Chrome&cbrver=123.0. 0.0&c=WEB&cver=2.20240327.00.00&cplayer=UNIPLAYER&cos=Windows&cosver=10.0&cplatform=DESKTOP (Simply accessing this URL will result in an error; you will need to include the session key set in the Youtube URL in the HTTP header, for example. Therefore, to confirm that such a request is working, it is necessary to actually make it work. (To be specific, open the Chrome Developer Console, open a Youtube video, find the one that accesses https://www.youtube.com/api/timedtext in the Network Access section, and check the contents of the video.)

It sometimes happens that all or most of the contents of events[].segs[].utf8 in the JSON data returned for this request are returned empty. Yes, this is true. This means that if you make multiple requests, you will get different results each time. We have confirmed that this issue is causing a situation where CaptionSpeaker is not able to retrieve the subtitles if the contents of events[].segs[].utf8 are empty.

However, this problem is caused by an inconvenience in the data returned by the API on the Youtube side. CaptionSpeaker works by retrieving subtitles added by Youtube, so if you cannot retrieve the subtitle data from the Youtube side, it will not work.

That is all I can say at this point.

動で説明いだだきありがとうございます。

確認してみましたところ、字幕データの読み出し時に字幕が読み出せない場合があるようでした。

具体的には、以下のようなURLを使って取得した字幕データに問題があります。 https://www.youtube.com/api/timedtext?v=Y3tqLF5zgfw&ei=aEsJZreROoqcvcAPmJ282AI&caps=asr&opi=112496729&xoaf=5&hl=ja&ip=0.0.0.0&ipbits=0&expire=1711910361&sparams=ip%2Cipbits%2Cexpire%2Cv%2Cei%2Ccaps%2Copi%2Cxoaf&signature=148018676E1CF8A9F31DD8F59F5CA3F5BA7EBF3E.106997E4D11FA315CC5863D1848C7067F76254B7&key=yt8&lang=fr-FR&fmt=json3&xorb=2&xobt=3&xovt=3&tlang=ja&cbr=Chrome&cbrver=123.0.0.0&c=WEB&cver=2.20240327.00.00&cplayer=UNIPLAYER&cos=Windows&cosver=10.0&cplatform=DESKTOP (単純にこのURLにアクセスしてもエラーするだけです。YoutubeのURL内で設定されるセッションキーなどをHTTPヘッダにいれるなどする必要があります。そのため、このようなリクエストが動作しているのを確認するには実際に動作させる必要があります。具体的にはChromeのデベロッパーコンソールを開き、Youtubeの動画を開いてネットワークアクセスの中から https://www.youtube.com/api/timedtext へとアクセスしているものを探し出してその中身を確認するのが良いでしょう)

このリクエストに対して返却されるJSONデータの中の events[].segs[].utf8 の中身のうちの全てまたは大半が空の状態で返却されるという事が時々発生しています。そうです。何度もリクエストすると得られる結果が毎回違うという事です。この問題によって、events[].segs[].utf8の中身が空の場合、CaptionSpeaker側で字幕を取得することができていないという状態が発生しているのを確認しました。

ただ、この問題はYoutube側のAPIが返却するデータに不都合があるという物になります。そのため、CaptionSpeakerの側で解決できる問題ではありません。CaptionSpeakerはYoutubeのつけた字幕を取得して動作するため、Youtube側からその字幕データが取得できない場合は動作しません。

少なくとも、私から現時点で言えるのは以上です。

limura commented 6 months ago

Note that this API is used by Youtube to display subtitles. Therefore, if an empty string is obtained from this API, the subtitle will not be displayed on Youtube. However, since the case where CaptionSpeaker obtains the subtitle and the case where Youtube obtains the subtitle are different API requests, it may happen that the subtitle is obtained on the CaptionSpeaker side but not displayed on the Youtube subtitle display side. Of course, the reverse is also possible.

なお、このAPIはYoutubeが字幕を表示する時に使用しているものです。そのため、このAPIで空文字列が得られた場合はYoutube上でも字幕が表示されないという動作をします。ただ、CaptionSpeakerが取得する場合とYoutubeの字幕が取得する場合のそれぞれは別のAPIリクエスになるため、CaptionSpeaker側では字幕が取れているがYoutubeの字幕表示側では字幕が表示されない、といった事は起こり得ます。もちろんその逆もありえます。

limura commented 6 months ago

暫く反応が無いようなのでcloseします。