File size: 3,970 Bytes
199eb26
89e36c5
 
 
 
 
 
 
 
 
 
199eb26
89e36c5
f95b474
 
 
 
 
d788666
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
af9a512
 
d788666
3779175
af9a512
 
3779175
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
---
title: Podcast Search
emoji: 🚀
colorFrom: green
colorTo: gray
sdk: streamlit
sdk_version: 1.41.1
app_file: src/app.py
pinned: false
license: mit
short_description: terapyon channel の検索
---

# podcast-search

Podcast terapyon channelを検索する仕組み


## 使い方


### タイトルリスト

- 以下のファイルを`store` フォルダに置く
- `title-list-202301-202501.parquet`
- 以下のカラムを持つ
  - id: int
  - date: str (2023-01-09)
  - length: int
  - audio: str (オーディオファイルURL)
  - title: str

タイトルリストファイルの例

<div>
<style scoped>
    .dataframe tbody tr th:only-of-type {
        vertical-align: middle;
    }

    .dataframe tbody tr th {
        vertical-align: top;
    }

    .dataframe thead th {
        text-align: right;
    }
</style>
<table border="1" class="dataframe">
  <thead>
    <tr style="text-align: right;">
      <th></th>
      <th>id</th>
      <th>date</th>
      <th>length</th>
      <th>audio</th>
      <th>title</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <th>0</th>
      <td>69</td>
      <td>2023-01-09</td>
      <td>20993616</td>
      <td>https://anchor.fm/s/14480e04/podcast/play/6323...</td>
      <td>#69 2023年新年挨拶から 2022年の振り返りと2023年の抱負</td>
    </tr>
    <tr>
      <th>1</th>
      <td>70</td>
      <td>2023-03-09</td>
      <td>103287296</td>
      <td>https://anchor.fm/s/14480e04/podcast/play/6621...</td>
      <td>#70 PyCon JP Association代表理事退任と今後の展望をIqbalさんと語る</td>
    </tr>
    <tr>
      <th>2</th>
      <td>71</td>
      <td>2023-03-22</td>
      <td>116393694</td>
      <td>https://anchor.fm/s/14480e04/podcast/play/6706...</td>
      <td>#71 hirokikyさんをゲストに 自然言語処理系AI Chat GPT / Whisp...</td>
    </tr>
    <tr>
      <th>3</th>
      <td>72</td>
      <td>2023-05-04</td>
      <td>49642320</td>
      <td>https://anchor.fm/s/14480e04/podcast/play/6976...</td>
      <td>#72 PyCon US 2023 ひとり振り返り</td>
    </tr>
    <tr>
      <th>4</th>
      <td>73</td>
      <td>2023-05-24</td>
      <td>150643013</td>
      <td>https://anchor.fm/s/14480e04/podcast/play/7094...</td>
      <td>#73 Nyohoさんをゲストに Scratchからディープラーニングや数学の話</td>
    </tr>
  </tbody>
</table>
</div>

### 文字データ作成

- dataフォルダをを作る(srcと同じ階層)
- dataフォルダに、srtファイルを入れる
  - (以下に従うと、srtファイルからIDが取得できる)
  - 拡張子を `.srt` とする
  - ファイル名に、ID(整数)が1つだけ入ってること
  - IDの前後に、 `-` または `_` で区切られいること
- 以下のスクリプトを実行する。 `store` フォルダに `parquet` ファイルが srtファイル分できる

```
% python src/episode.py
```

### データベース作成

以下のコマンドで、テーブル作成から必要な3つのデータをDuckDB(永続化)を作る

```
% python src/store.py all
```

上記のコマンドの詳細

- テーブル作成 create table
  - `python src/store.py create`
- タイトルリスト insert
  - `python src/store.py podcastinsert`
- エピソードとテキスト insert
  - `python src/store.py episodeinsert`
- ベクトル化 embedding
  - `python src/store.py embed`
- ベクトルデータ index
  - `python src/store.py index`


### 検索UI

```
% streamlit run src/app.py
```

- Podcastタイトル(複数)を選ぶ。未選択の場合すべてとなる
- 検索したいワードをテキストボックスに入力
- 10個のセンテンス(文章)候補が出てくる
- 表の左をクリックすると、下部に文字列が表示される
- 音声のタイミング(分・秒)が表示される
- そのタイミングの音声がその場で聞ける


https://github.com/user-attachments/assets/98e85be4-a633-4bdc-900d-9a7c06818d9b