1 |
f646c127
|
みぞ@CrazyBeatCoder
|
# TimelineTalker
|
2 |
|
|
Raspberry Pi でゆっくり達に Twitter & Mastodon タイムラインを読み上げてもらう
|
3 |
b081855b
|
みぞ@CrazyBeatCoder
|
|
4 |
|
|
## 使い方
|
5 |
|
|
|
6 |
|
|
### 動作確認環境
|
7 |
|
|
|
8 |
|
|
| | Version |
|
9 |
|
|
|:-------------|:---------------------------------|
|
10 |
|
|
| ボード | Raspberry Pi 3 Model B |
|
11 |
|
|
| OS | Raspbian GNU/Linux 9.4 (stretch) |
|
12 |
|
|
| Java | OpenJDK 9-Raspbian |
|
13 |
|
|
| AquesTalk Pi | Ver.1.00 |
|
14 |
|
|
|
15 |
|
|
### Twitter API Key を取得する (任意)
|
16 |
|
|
|
17 |
|
|
[Twitter Application Management](https://apps.twitter.com) から、下記 4 つの Key を取得します。
|
18 |
|
|
|
19 |
|
|
* Consumer Key (API Key)
|
20 |
|
|
* Consumer Secret (API Secret)
|
21 |
|
|
* Access Token
|
22 |
|
|
* Access Token Secret
|
23 |
|
|
|
24 |
|
|
[phi 様の記事](http://phiary.me/twitter-api-key-get-how-to/)がわかりやすいので、詳細手順は割愛します。
|
25 |
|
|
|
26 |
|
|
Access level は Read and Write がデフォルトのようですが、本アプリに投稿機能は無いため Read only に変更しても問題ありません。
|
27 |
|
|
|
28 |
|
|
もし、Access Token の発行後に Access level を変更したのであれば、Access Token を Regenerate してください。
|
29 |
|
|
|
30 |
|
|
### Mastodon の Access Token を取得する (任意)
|
31 |
|
|
|
32 |
|
|
例) mstdn.jp の場合
|
33 |
|
|
|
34 |
|
|
1. https://mstdn.jp/settings/applications/new にアクセス
|
35 |
|
|
2. 下記を入力・設定して送信
|
36 |
|
|
* アプリの名前: 任意の値
|
37 |
|
|
* アプリのウェブサイト: 任意の値
|
38 |
|
|
* アクセス権: read のみをチェック
|
39 |
|
|
3. Access Token が発行される
|
40 |
|
|
|
41 |
|
|
### TimelineTalker および音声合成アプリ「AquesTalk Pi」のダウンロード
|
42 |
|
|
|
43 |
|
|
1. [AquesTalk Pi](https://www.a-quest.com/products/aquestalkpi.html) をダウンロード、および tgz ファイルを展開
|
44 |
|
|
2. [TimelineTalker.jar](http://redmine.mizo0203.com/projects/timeline-talker/files) から最新版をダウンロード
|
45 |
|
|
3. ダウンロードおよび展開したファイルを下記のように配置
|
46 |
|
|
* TimelineTalker.jar
|
47 |
|
|
* aquestalkpi/AquesTalkPi
|
48 |
|
|
* aquestalkpi/aq_dic
|
49 |
|
|
|
50 |
|
|
### TimelineTalker.jar を起動
|
51 |
|
|
|
52 |
|
|
Raspberry Pi にスピーカーを接続して、下記コマンドを実行してください。
|
53 |
|
|
|
54 |
|
|
引数 \<Mastodon Instance Name\> は Mastodon のインスタンス名に置き換えてください。 例) mstdn.jp
|
55 |
|
|
その他の引数は、上記で取得した値に置き換えてください
|
56 |
|
|
|
57 |
|
|
ゆっくり霊夢が『アプリケーションを起動しました』と発声します。その後、タイムラインに更新があれば、ゆっくり霊夢・ゆっくり魔理沙が交互にツイートを読み上げます。
|
58 |
|
|
|
59 |
|
|
#### Twitter と Mastodon の両方を読み上げる場合は 6 つの引数を指定
|
60 |
|
|
|
61 |
|
|
```bash
|
62 |
|
|
$ nohup java -jar TimelineTalker.jar <Twitter Consumer Key> <Twitter Consumer Secret> <Twitter Access Token> <Twitter Access Token Secret> <Mastodon Instance Name> <Mastodon Account's Access Token> &
|
63 |
|
|
```
|
64 |
|
|
|
65 |
|
|
#### Twitter のみを読み上げる場合は 4 つの引数を指定
|
66 |
|
|
|
67 |
|
|
```bash
|
68 |
|
|
$ nohup java -jar TimelineTalker.jar <Twitter Consumer Key> <Twitter Consumer Secret> <Twitter Access Token> <Twitter Access Token Secret> &
|
69 |
|
|
```
|
70 |
|
|
|
71 |
|
|
#### Mastodon のみを両方を読み上げる場合は 2 つの引数を指定
|
72 |
|
|
|
73 |
|
|
```bash
|
74 |
|
|
$ nohup java -jar TimelineTalker.jar <Mastodon Instance Name> <Mastodon Account's Access Token> &
|
75 |
|
|
```
|
76 |
|
|
|
77 |
|
|
## 使用しているもの
|
78 |
|
|
|
79 |
|
|
### 音声合成アプリ「AquesTalk Pi」
|
80 |
|
|
|
81 |
|
|
YouTube やニコニコ動画でおなじみの「ゆっくりボイス」とは、[株式会社アクエスト](https://www.a-quest.com/index.html)社製の音声合成エンジン「[AquesTalk](https://www.a-quest.com/products/aquestalk_1.html)」によって生成された音声です。有名な読み上げフリーソフトに「[SofTalk](https://www35.atwiki.jp/softalk/)」や「[棒読みちゃん](http://chi.usamimi.info/Program/Application/BouyomiChan/)」がありますが、いずれにも「AquesTalk」が使われています。
|
82 |
|
|
|
83 |
|
|
音声合成アプリ「[AquesTalk Pi](https://www.a-quest.com/products/aquestalkpi.html)」には、ARM 用にビルドされた「AquesTalk」が使われています。また、言語処理エンジン「[AqKanji2Koe](https://www.a-quest.com/products/aqkanji2koe.html)」もアプリに含まれるため、漢字も読み上げてくれます。
|
84 |
|
|
|
85 |
|
|
個人かつ非営利に限り、無償で使用することができます。
|
86 |
|
|
|
87 |
|
|
### Java ライブラリ「Twitter4J」
|
88 |
|
|
|
89 |
|
|
Twitter の statuses/home_timeline API を使用するため、[Twitter4J](http://twitter4j.org/)を使用しています。
|
90 |
|
|
|
91 |
|
|
Apache License 2.0 で使用できる Twitter 非公式のライブラリです。
|
92 |
|
|
|
93 |
|
|
![powered-by-twitter4j-138x30.png](https://qiita-image-store.s3.amazonaws.com/0/40619/6e7bb573-0590-e434-42f3-759355d3971c.png "powered-by-twitter4j-138x30.png")
|
94 |
|
|
|
95 |
|
|
### Java ライブラリ「sys1yagi/mastodon4j」
|
96 |
|
|
|
97 |
|
|
Mastodon の Streaming API を使用するため、[sys1yagi/mastodon4j](https://github.com/sys1yagi/mastodon4j)を使用しています。
|
98 |
|
|
|
99 |
|
|
MIT License で使用できるライブラリです。
|
100 |
|
|
|
101 |
|
|
[公式ドキュメント](https://github.com/tootsuite/documentation/blob/master/Using-the-API/Libraries.md)で Mastodon API が使用できるライブラリ一覧が紹介されています。
|