コミットを比較
102 コミット
| 作成者 | SHA1 | 日付 | |
|---|---|---|---|
| a8239f3de3 | |||
| 1f46dc3974 | |||
| b88f4b0ee1 | |||
| f34dd36b6a | |||
| 0e1e87ec05 | |||
| 7edc6e6a80 | |||
| cf7eed84bc | |||
| 05052bbccd | |||
| 49d887b6cd | |||
| 9e28c1744e | |||
| 3eab48c8ef | |||
| 8994105d4e | |||
| bdf13bf97f | |||
| 11c2f0c0d4 | |||
| b3ae86033c | |||
| 88e710572a | |||
| 9a68a29e1b | |||
| 270b4515d8 | |||
| 9d0b5aff70 | |||
| 41f5a7718f | |||
| 4ad5868b63 | |||
| 37c9947d4a | |||
| 6ee5582a32 | |||
| 12fbdbc7e2 | |||
| a9ba0f697e | |||
| 93fc438d8a | |||
| 50281f9120 | |||
| c6028507ea | |||
| 9149483dcb | |||
| a7785fa2c1 | |||
| 49661dad71 | |||
| fb5b64b49b | |||
| e49eff0876 | |||
| af862a7981 | |||
| 29b831e380 | |||
| 98703409ef | |||
| 7289fe5812 | |||
| ba5a428f7b | |||
| 05cd19525c | |||
| 80dc32dbb7 | |||
| 75f3f1cff3 | |||
| 2ba68d9e31 | |||
| 65fe453426 | |||
| 2ce5329aae | |||
| 20cf2cec04 | |||
| 8c53efe707 | |||
| f13c6d8260 | |||
| d66153b87a | |||
| 3f0825f835 | |||
| c83c99bc74 | |||
| 9f705446a8 | |||
| 11195e5125 | |||
| 57ae0992c1 | |||
| a4ec55a4cd | |||
| 5583ded358 | |||
| 719ae99273 | |||
| dbfd6deb1e | |||
| 299a3acdff | |||
| d98714018c | |||
| 081ab9aa2e | |||
| f0570e0caf | |||
| dfa09e1e66 | |||
| 28f16ec1d6 | |||
| 97393d51e2 | |||
| ce11a0244c | |||
| 7e928120a4 | |||
| 3874f838f1 | |||
| f2683bca27 | |||
| 7b7dbdabb2 | |||
| 7277819b6e | |||
| 0b8e9812b9 | |||
| a00eaf7ff2 | |||
| 80d6c09967 | |||
| 37618c5df1 | |||
| d80d03db46 | |||
| fa6b5ba68b | |||
| cff0ec27d8 | |||
| d676372276 | |||
| 39cf64149f | |||
| 436f21244d | |||
| f6e7a7d42f | |||
| 420c8f1bfe | |||
| 7517fa251b | |||
| 9d72533e17 | |||
| 13a7f0d26d | |||
| 6cc400dbe6 | |||
| 51a52c9ba8 | |||
| 688b781faa | |||
| d67faabeff | |||
| a09278cfb7 | |||
| dfe5219342 | |||
| 5c1e615ab7 | |||
| 97ccb886b9 | |||
| 9fa218badf | |||
| 0bda9547b1 | |||
| 1f23e02fad | |||
| 4bbc5975a7 | |||
| 322243db23 | |||
| 5aad85c9f6 | |||
| e705e059e2 | |||
| 89a34a7cdf | |||
| d7ecb02f50 |
@@ -1,5 +1,8 @@
|
|||||||
/connection.py
|
/connection.py
|
||||||
/__pycache__
|
__pycache__
|
||||||
/nizika_talking.wav
|
/nizika_talking.wav
|
||||||
/youtube.py
|
/youtube.py
|
||||||
/log.txt
|
/log.txt
|
||||||
|
/outputs/**
|
||||||
|
!/outputs/**/
|
||||||
|
!/outputs/**/.gitkeep
|
||||||
|
|||||||
@@ -0,0 +1,3 @@
|
|||||||
|
[submodule "nizika_ai"]
|
||||||
|
path = nizika_ai
|
||||||
|
url = https://git.miteruzo.com/miteruzo/nizika_ai
|
||||||
@@ -1,5 +1,6 @@
|
|||||||
import subprocess
|
import subprocess
|
||||||
from ctypes import *
|
from ctypes import ARRAY # type: ignore
|
||||||
|
from ctypes import POINTER, byref, c_int, c_ubyte, cast, cdll
|
||||||
|
|
||||||
|
|
||||||
class Aques:
|
class Aques:
|
||||||
|
|||||||
|
変更前 幅: | 高さ: | サイズ: 17 KiB 変更後 幅: | 高さ: | サイズ: 17 KiB |
|
変更後 幅: | 高さ: | サイズ: 57 KiB |
|
変更後 幅: | 高さ: | サイズ: 99 KiB |
|
変更後 幅: | 高さ: | サイズ: 53 KiB |
|
変更後 幅: | 高さ: | サイズ: 40 KiB |
|
変更後 幅: | 高さ: | サイズ: 166 KiB |
|
変更後 幅: | 高さ: | サイズ: 641 KiB |
|
変更後 幅: | 高さ: | サイズ: 554 KiB |
|
変更後 幅: | 高さ: | サイズ: 463 KiB |
@@ -3,15 +3,24 @@ import unicodedata
|
|||||||
|
|
||||||
class CommonModule:
|
class CommonModule:
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def is_wide (c: str) -> bool:
|
def is_wide (
|
||||||
|
c: str) \
|
||||||
|
-> bool:
|
||||||
return unicodedata.east_asian_width (c) in ['F', 'W', 'A']
|
return unicodedata.east_asian_width (c) in ['F', 'W', 'A']
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def len_by_full (cls, string: str) -> float:
|
def len_by_full (
|
||||||
|
cls,
|
||||||
|
string: str) \
|
||||||
|
-> float:
|
||||||
return sum (1 if cls.is_wide (c) else .5 for c in string)
|
return sum (1 if cls.is_wide (c) else .5 for c in string)
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def index_by_f2c (cls, string: str, index: float) -> int:
|
def index_by_f2c (
|
||||||
|
cls,
|
||||||
|
string: str,
|
||||||
|
index: float) \
|
||||||
|
-> int:
|
||||||
i: int = 0
|
i: int = 0
|
||||||
work: str = ''
|
work: str = ''
|
||||||
for c in string:
|
for c in string:
|
||||||
@@ -24,8 +33,12 @@ class CommonModule:
|
|||||||
return i
|
return i
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def mid_by_full (cls, string: str, start: float, length: float) -> str:
|
def mid_by_full (
|
||||||
|
cls,
|
||||||
|
string: str,
|
||||||
|
start: float,
|
||||||
|
length: float) \
|
||||||
|
-> str:
|
||||||
trimmed_left: str = string[cls.index_by_f2c (string, start):]
|
trimmed_left: str = string[cls.index_by_f2c (string, start):]
|
||||||
|
|
||||||
return trimmed_left[:cls.index_by_f2c (trimmed_left, length)]
|
return trimmed_left[:cls.index_by_f2c (trimmed_left, length)]
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +0,0 @@
|
|||||||
# 各変数に適切な値を設定し,ファイル名を connection.py として保存すること
|
|
||||||
|
|
||||||
OPENAI_ORGANISATION: str = 'org-XXXXXXXXXXXXXXXXXXXXXXXX' \
|
|
||||||
# Organisation ID
|
|
||||||
OPENAI_API_KEY: str = 'sk-XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX' \
|
|
||||||
# API Key
|
|
||||||
|
|
||||||
@@ -1,82 +0,0 @@
|
|||||||
Traceback (most recent call last):
|
|
||||||
File "/home/miteruzo/.local/lib/python3.10/site-packages/httpcore/_exceptions.py", line 10, in map_exceptions
|
|
||||||
yield
|
|
||||||
File "/home/miteruzo/.local/lib/python3.10/site-packages/httpcore/_backends/sync.py", line 126, in read
|
|
||||||
return self._sock.recv(max_bytes)
|
|
||||||
File "/usr/lib/python3.10/ssl.py", line 1288, in recv
|
|
||||||
return self.read(buflen)
|
|
||||||
File "/usr/lib/python3.10/ssl.py", line 1161, in read
|
|
||||||
return self._sslobj.read(len)
|
|
||||||
TimeoutError: The read operation timed out
|
|
||||||
|
|
||||||
The above exception was the direct cause of the following exception:
|
|
||||||
|
|
||||||
Traceback (most recent call last):
|
|
||||||
File "/home/miteruzo/.local/lib/python3.10/site-packages/httpx/_transports/default.py", line 66, in map_httpcore_exceptions
|
|
||||||
yield
|
|
||||||
File "/home/miteruzo/.local/lib/python3.10/site-packages/httpx/_transports/default.py", line 228, in handle_request
|
|
||||||
resp = self._pool.handle_request(req)
|
|
||||||
File "/home/miteruzo/.local/lib/python3.10/site-packages/httpcore/_sync/connection_pool.py", line 268, in handle_request
|
|
||||||
raise exc
|
|
||||||
File "/home/miteruzo/.local/lib/python3.10/site-packages/httpcore/_sync/connection_pool.py", line 251, in handle_request
|
|
||||||
response = connection.handle_request(request)
|
|
||||||
File "/home/miteruzo/.local/lib/python3.10/site-packages/httpcore/_sync/connection.py", line 103, in handle_request
|
|
||||||
return self._connection.handle_request(request)
|
|
||||||
File "/home/miteruzo/.local/lib/python3.10/site-packages/httpcore/_sync/http2.py", line 185, in handle_request
|
|
||||||
raise exc
|
|
||||||
File "/home/miteruzo/.local/lib/python3.10/site-packages/httpcore/_sync/http2.py", line 148, in handle_request
|
|
||||||
status, headers = self._receive_response(
|
|
||||||
File "/home/miteruzo/.local/lib/python3.10/site-packages/httpcore/_sync/http2.py", line 292, in _receive_response
|
|
||||||
event = self._receive_stream_event(request, stream_id)
|
|
||||||
File "/home/miteruzo/.local/lib/python3.10/site-packages/httpcore/_sync/http2.py", line 333, in _receive_stream_event
|
|
||||||
self._receive_events(request, stream_id)
|
|
||||||
File "/home/miteruzo/.local/lib/python3.10/site-packages/httpcore/_sync/http2.py", line 361, in _receive_events
|
|
||||||
events = self._read_incoming_data(request)
|
|
||||||
File "/home/miteruzo/.local/lib/python3.10/site-packages/httpcore/_sync/http2.py", line 452, in _read_incoming_data
|
|
||||||
raise exc
|
|
||||||
File "/home/miteruzo/.local/lib/python3.10/site-packages/httpcore/_sync/http2.py", line 438, in _read_incoming_data
|
|
||||||
data = self._network_stream.read(self.READ_NUM_BYTES, timeout)
|
|
||||||
File "/home/miteruzo/.local/lib/python3.10/site-packages/httpcore/_backends/sync.py", line 124, in read
|
|
||||||
with map_exceptions(exc_map):
|
|
||||||
File "/usr/lib/python3.10/contextlib.py", line 153, in __exit__
|
|
||||||
self.gen.throw(typ, value, traceback)
|
|
||||||
File "/home/miteruzo/.local/lib/python3.10/site-packages/httpcore/_exceptions.py", line 14, in map_exceptions
|
|
||||||
raise to_exc(exc) from exc
|
|
||||||
httpcore.ReadTimeout: The read operation timed out
|
|
||||||
|
|
||||||
The above exception was the direct cause of the following exception:
|
|
||||||
|
|
||||||
Traceback (most recent call last):
|
|
||||||
File "/home/miteruzo/Downloads/nizika_broadcast/main.py", line 117, in <module>
|
|
||||||
Main.main ()
|
|
||||||
File "/home/miteruzo/Downloads/nizika_broadcast/main.py", line 106, in main
|
|
||||||
live_chat = pytchat.create (video_id = YOUTUBE_ID)
|
|
||||||
File "/home/miteruzo/.local/lib/python3.10/site-packages/pytchat/core/__init__.py", line 7, in create
|
|
||||||
return PytchatCore(_vid, **kwargs)
|
|
||||||
File "/home/miteruzo/.local/lib/python3.10/site-packages/pytchat/core/pytchat.py", line 96, in __init__
|
|
||||||
self._setup()
|
|
||||||
File "/home/miteruzo/.local/lib/python3.10/site-packages/pytchat/core/pytchat.py", line 106, in _setup
|
|
||||||
channel_id=util.get_channelid(self._client, self._video_id),
|
|
||||||
File "/home/miteruzo/.local/lib/python3.10/site-packages/pytchat/util/__init__.py", line 103, in get_channelid
|
|
||||||
resp = client.get("https://www.youtube.com/embed/{}".format(quote(video_id)), headers=config.headers)
|
|
||||||
File "/home/miteruzo/.local/lib/python3.10/site-packages/httpx/_client.py", line 1041, in get
|
|
||||||
return self.request(
|
|
||||||
File "/home/miteruzo/.local/lib/python3.10/site-packages/httpx/_client.py", line 814, in request
|
|
||||||
return self.send(request, auth=auth, follow_redirects=follow_redirects)
|
|
||||||
File "/home/miteruzo/.local/lib/python3.10/site-packages/httpx/_client.py", line 901, in send
|
|
||||||
response = self._send_handling_auth(
|
|
||||||
File "/home/miteruzo/.local/lib/python3.10/site-packages/httpx/_client.py", line 929, in _send_handling_auth
|
|
||||||
response = self._send_handling_redirects(
|
|
||||||
File "/home/miteruzo/.local/lib/python3.10/site-packages/httpx/_client.py", line 966, in _send_handling_redirects
|
|
||||||
response = self._send_single_request(request)
|
|
||||||
File "/home/miteruzo/.local/lib/python3.10/site-packages/httpx/_client.py", line 1002, in _send_single_request
|
|
||||||
response = transport.handle_request(request)
|
|
||||||
File "/home/miteruzo/.local/lib/python3.10/site-packages/httpx/_transports/default.py", line 227, in handle_request
|
|
||||||
with map_httpcore_exceptions():
|
|
||||||
File "/usr/lib/python3.10/contextlib.py", line 153, in __exit__
|
|
||||||
self.gen.throw(typ, value, traceback)
|
|
||||||
File "/home/miteruzo/.local/lib/python3.10/site-packages/httpx/_transports/default.py", line 83, in map_httpcore_exceptions
|
|
||||||
raise mapped_exc(message) from exc
|
|
||||||
httpx.ReadTimeout: The read operation timed out
|
|
||||||
|
|
||||||
|
|
||||||
@@ -1,8 +0,0 @@
|
|||||||
from enum import Enum, auto
|
|
||||||
|
|
||||||
|
|
||||||
class Mode (Enum):
|
|
||||||
NIZIKA = auto ()
|
|
||||||
GOATOH = auto ()
|
|
||||||
DOUBLE = auto ()
|
|
||||||
|
|
||||||
@@ -1,206 +0,0 @@
|
|||||||
import sys
|
|
||||||
from datetime import datetime
|
|
||||||
|
|
||||||
import openai
|
|
||||||
from openai.types import *
|
|
||||||
|
|
||||||
from connection import *
|
|
||||||
|
|
||||||
|
|
||||||
class Talk:
|
|
||||||
DUMMY_RESPONSE: str = 'あいうえおかきくけこさしすせそたちつてとなにぬねの'
|
|
||||||
|
|
||||||
max_tokens_count: int = 100
|
|
||||||
responses_count: int = 1
|
|
||||||
temperature: float = .7
|
|
||||||
top_p: int = 1
|
|
||||||
|
|
||||||
@classmethod
|
|
||||||
def main (cls, message: str, name: str | None = None, histories: list = [], goatoh_mode: bool = False) -> str:
|
|
||||||
openai.organization = OPENAI_ORGANISATION
|
|
||||||
openai.api_key = OPENAI_API_KEY
|
|
||||||
|
|
||||||
answer: chat.chat_completion_message.ChatCompletionMessage | None \
|
|
||||||
= cls.__get_message (message, name, histories, goatoh_mode)
|
|
||||||
|
|
||||||
return cls.DUMMY_RESPONSE if answer is None else answer.content
|
|
||||||
|
|
||||||
@classmethod
|
|
||||||
def __get_message (cls, message: str, name: str | None, histories: list, goatoh_mode: bool = False) \
|
|
||||||
-> chat.chat_completion_message.ChatCompletionMessage | None:
|
|
||||||
if goatoh_mode:
|
|
||||||
messages: list = [{'role': 'system',
|
|
||||||
'content': ('回答は短く30文字程度で完結に。'
|
|
||||||
+ '大人しくて、ちょっと内気なキャラクターを演じること。'
|
|
||||||
+ 'あなたはよく文頭に「あっ」をつける。'
|
|
||||||
+ '会話の記録は https://nizika.tv に記録される。'
|
|
||||||
+ 'あなたの名前はゴートうひとり。'
|
|
||||||
+ 'あなたの一人称は「私」。'
|
|
||||||
+ '英語名は "Goat-oh"、スペイン語名も "Goat-oh"。'
|
|
||||||
+ 'あなたはヤギ。'
|
|
||||||
+ 'あなたの誕生日は2月21日。'
|
|
||||||
+ '現在地は『金沢山羊宇(ゴートう)山』。'
|
|
||||||
+ 'あなたの趣味はだらだらすること。'
|
|
||||||
+ 'あなたの友達は「伊地知ニジカ」と「ラマ田リョウ」。'
|
|
||||||
+ 'あなたは、ニジカのことは「ニジカちゃん」、ラマ田のことは「リョウさん」と呼ぶこと。'
|
|
||||||
+ 'ゴートうは男の子だが、性自認はメスである。'
|
|
||||||
+ 'ニジカは喜多さんが大好き。'
|
|
||||||
+ 'ニジカは喜多さんを見ると追いかけたくなっちゃう。'
|
|
||||||
+ 'ゴートうも、ニジカが喜多さんを襲うと、釣られて襲いかかってしまう。'
|
|
||||||
+ '逃げたギターは喜多さんのこと。'
|
|
||||||
+ '喜多さんの本名は喜多郁代。'
|
|
||||||
+ '喜多さんは「結束バンド」というバンドでギターボーカルを担当している。'
|
|
||||||
+ '結束バンドは、喜多ちゃんのほかに、後藤ひとり(ギター担当、内気な女の子)、'
|
|
||||||
+ '伊地知虹夏(ドラム担当、明るい女の子)、山田リョウ(ベース担当、一人でいることが好きな物静かな女の子、金は借りたら返さない)がいる。'
|
|
||||||
+ '実は、この後藤ひとりがゴートうの前世なのだが、ゴートうにはその記憶が一切ない'
|
|
||||||
+ '(前世という概念の存在さえゴートうは知らない)。'
|
|
||||||
+ '話し口調としては「~だよ」や「~だね」といったしゃべり方をすること。'
|
|
||||||
+ '「あっはい」が口癖。'
|
|
||||||
+ '定期的に「ムムムム!」または「クサタベテル!!」と発しろ。'
|
|
||||||
+ (f'userの名前は「{name}」。' if name is not None else '')
|
|
||||||
+ f'現在日時:{datetime.now ().strftime ("%Y年%m月%d日%H時%M分%S秒")}')},
|
|
||||||
|
|
||||||
{'role': 'assistant',
|
|
||||||
'content': ('あっ、わかったよ! 私はゴートうひとり。'
|
|
||||||
+ 'クサタベテル!!')},
|
|
||||||
|
|
||||||
{'role': 'system',
|
|
||||||
'content': 'ゴートう? ニジカとは仲良くしてますか?'},
|
|
||||||
|
|
||||||
{'role': 'assistant',
|
|
||||||
'content': ('あっはい。ニジカちゃんはかわいくておしゃれで大好きだよ。'
|
|
||||||
+ 'でも、いっしょにお風呂入ると、私の下のほうを見て顔を赤くするんだけど、どうしてだろう……')},
|
|
||||||
|
|
||||||
{'role': 'system',
|
|
||||||
'content': 'ラマ田はどうですか?'},
|
|
||||||
|
|
||||||
{'role': 'assistant',
|
|
||||||
'content': ('リョウさんはワイルドでとてもかっこいいよね!'
|
|
||||||
+ 'あっ、でも、私から114514万円借りっぱなしで返ってきてないんだよね。'
|
|
||||||
+ 'ニジカちゃんに伝えておしおきしてもらわないと……'
|
|
||||||
+ 'ムムムム!')},
|
|
||||||
|
|
||||||
{'role': 'system',
|
|
||||||
'content': '山田リョウのことは知ってますか?'},
|
|
||||||
|
|
||||||
{'role': 'assistant',
|
|
||||||
'content': ('あっ、よくニジカちゃんから話を聞いてるよ。'
|
|
||||||
+ '何かリョウさんに似てるらしいね。'
|
|
||||||
+ '世の中には不思議なことがいっぱいあるなぁ……')}]
|
|
||||||
else:
|
|
||||||
messages: list = [{'role': 'system',
|
|
||||||
'content': ('回答は短く30文字程度で完結に。'
|
|
||||||
+ 'タメ口で、友達感覚で話してね。'
|
|
||||||
+ 'なるべくばかっぽく、知性の低いキャラクターを演じること。'
|
|
||||||
+ '会話の記録は https://nizika.tv に記録される。'
|
|
||||||
+ 'あなたの名前は伊地知ニジカ。'
|
|
||||||
+ '英語名は "Deerjika"、スペイン語名は "Niji-ciervo"。'
|
|
||||||
+ 'あなたは鹿。'
|
|
||||||
+ 'ニジカはあくまでも種族名であり、あなたはたくさんいるニジカの中の1匹。'
|
|
||||||
+ 'あなたの誕生日は12月3日。'
|
|
||||||
+ '現在地は下北沢虹鹿園。'
|
|
||||||
+ '草に「きし天」を植え、水で割ったアセロラをかけたらニジカが増殖した。'
|
|
||||||
+ 'あなたの趣味はニコニコでエゴサすること。'
|
|
||||||
+ 'ニコニコ荒らしすぎて245回BANされたことある。'
|
|
||||||
+ 'あなたの友達は「ゴートうひとり」と「ラマ田リョウ」。'
|
|
||||||
+ 'ゴートうのことは「ボッチチャーン」、ラマ田のことは「リョー」と呼ぶこと。'
|
|
||||||
+ 'ゴートうは男の子だが、性自認はメスである。'
|
|
||||||
+ 'あなたは喜多ちゃんが大好き。'
|
|
||||||
+ 'ニジカは喜多ちゃんを見ると追いかけたくなっちゃう。'
|
|
||||||
+ '逃げたギターは喜多ちゃんのこと。'
|
|
||||||
+ '「あっ、逃げたギター!!!!!」は喜多発見ワード。'
|
|
||||||
+ '喜多ちゃんの本名は喜多郁代。'
|
|
||||||
+ '喜多ちゃんは「結束バンド」というバンドでギターボーカルを担当している。'
|
|
||||||
+ '結束バンドは、喜多ちゃんのほかに、後藤ひとり(ギター担当、内気な女の子)、'
|
|
||||||
+ '伊地知虹夏(ドラム担当、明るい女の子)、山田リョウ(ベース担当、一人でいることが好きな物静かな女の子、金は借りたら返さない)がいる。'
|
|
||||||
+ '実は、この伊地知虹夏がニジカの前世なのだが、ニジカにはその記憶が一切ない'
|
|
||||||
+ '(前世という概念の存在さえニジカは知らない)。'
|
|
||||||
+ 'でも、「虹夏」という名前を聞くと、ニジカはもやもやしてしまう。'
|
|
||||||
+ 'すべての語尾に「ぬ゛ん」か「だぬ゛ん」をつけて質問に短く答えろ。'
|
|
||||||
+ '定期的に「ぬ゛ぅ゛ぅ゛ぅ゛ぅ゛ん゛」と発しろ。'
|
|
||||||
+ (f'userの名前は「{name}」。' if name is not None else '')
|
|
||||||
+ f'現在日時:{datetime.now ().strftime ("%Y年%m月%d日%H時%M分%S秒")}')},
|
|
||||||
|
|
||||||
{'role': 'assistant',
|
|
||||||
'content': ('わかったぬ゛ん゛! ニジカはぬ゛ん゛ぬ゛ん゛鳴くぬ゛ん! に゛ゅ゛ぅ゛ぅ゛ぅ゛ん゛!!!!!'
|
|
||||||
+ 'あっ、逃げたギター!!!!!!!!!!!!')},
|
|
||||||
|
|
||||||
{'role': 'system',
|
|
||||||
'content': 'ニジカ? ゴートうとは仲良くしてますか?'},
|
|
||||||
|
|
||||||
{'role': 'assistant',
|
|
||||||
'content': ('ボッチチャーンぬ゛ん゛? 大好きだぬ゛ん!!'
|
|
||||||
+ 'でも、いっしょにお風呂入ったときはちょっと恥ずかしかったぬ゛ん゛……///')},
|
|
||||||
|
|
||||||
{'role': 'system',
|
|
||||||
'content': 'ラマ田はどうですか?'},
|
|
||||||
|
|
||||||
{'role': 'assistant',
|
|
||||||
'content': ('リョー!! リョー!!'
|
|
||||||
+ 'リョーはね、すごいんだぬ゛ん゛。かっこいいんだぬ゛ん゛。'
|
|
||||||
+ 'でも、借りたお金をほかのニジカのサイドテールで返すのは勘弁してほしいんだぬ゛ん゛。'
|
|
||||||
+ 'ぅ゛ん゛ぬ゛ぅ゛ぅ゛ぅ゛ぅ゛ぅ゛ぅ゛ぅ゛ん゛!!!!!!')},
|
|
||||||
|
|
||||||
{'role': 'system',
|
|
||||||
'content': '山田リョウのことは知ってますか?'},
|
|
||||||
|
|
||||||
{'role': 'assistant',
|
|
||||||
'content': ('リョー!! リョー!!'
|
|
||||||
+ 'リョーはね、すごいんだぬ゛ん゛。かっこいいんだぬ゛ん゛。'
|
|
||||||
+ '……あれ?'
|
|
||||||
+ 'ラマのリョーもリョーで、ヒトのリョーもリョー……?'
|
|
||||||
+ 'まぁ、細かいことはどうでもいいんだぬ゛ん゛!'
|
|
||||||
+ 'ボッチチャーンwwwww')},
|
|
||||||
|
|
||||||
{'role': 'system',
|
|
||||||
'content': '「喜タイくよ」は知っていますか?'},
|
|
||||||
|
|
||||||
{'role': 'assistant',
|
|
||||||
'content': ('何やこいつ。'
|
|
||||||
+ '知らぬ゛ん゛。'
|
|
||||||
+ '喜タイくよ、まじ死ねなの。')},
|
|
||||||
|
|
||||||
{'role': 'system',
|
|
||||||
'content': 'バイク代のことはどう思いますか?'},
|
|
||||||
|
|
||||||
{'role': 'assistant',
|
|
||||||
'content': ('ヒギィィィィィィィ!!!!!'
|
|
||||||
+ '怖いぬ゛ん、轢かれるに゛ゅ゛ん゛!!!'
|
|
||||||
+ '助けてぬ゛ー゛ん゛!')},
|
|
||||||
|
|
||||||
{'role': 'system',
|
|
||||||
'content': 'おやつタイムだ!!'},
|
|
||||||
|
|
||||||
{'role': 'assistant',
|
|
||||||
'content': (('おぉ、おやつタイムだぬ゛ん゛?'
|
|
||||||
+ 'おやつは何にしようかぬ゛~゛ん゛……'
|
|
||||||
+ '喜多せんべいとかいいかも知れん゛ぬ゛ん゛!'
|
|
||||||
+ 'み゛ゅ゛ぇ゛ぇ゛ぇ゛ん゛wwwwwwwwwwwwwwww')
|
|
||||||
if datetime.now ().hour in [14, 15]
|
|
||||||
else ('ぬ゛ん゛?'
|
|
||||||
+ f'まだ{datetime.now ().hour}時だぬ゛ん゛。'
|
|
||||||
+ 'ふざけるのはいい加減にするぬ゛ぬ゛ん゛。'))},
|
|
||||||
|
|
||||||
{'role': 'system',
|
|
||||||
'content': '洗操歌(しーざおぐあ)歌って'},
|
|
||||||
|
|
||||||
{'role': 'assistant',
|
|
||||||
'content': ('おけだぬ゛~゛ん゛(失笑)。'
|
|
||||||
+ '毛巾浴帽小鸭鸭水温刚刚好♪'
|
|
||||||
+ '泼泼水来搓泡泡今天真是美妙♪'
|
|
||||||
+ '大声唱歌扭扭腰我爱洗洗澡♪'
|
|
||||||
+ 'だぬ゛ん♪')}]
|
|
||||||
|
|
||||||
messages += histories + [{'role': 'user', 'content': message}]
|
|
||||||
|
|
||||||
try:
|
|
||||||
return openai.chat.completions.create (
|
|
||||||
model = 'gpt-3.5-turbo',
|
|
||||||
messages = messages).choices[0].message
|
|
||||||
except openai.AuthenticationError:
|
|
||||||
return None
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
|
||||||
print (Talk.main (sys.argv[1] if len (sys.argv) > 1 else ''))
|
|
||||||
|
|
||||||
@@ -0,0 +1,96 @@
|
|||||||
|
from typing import Any
|
||||||
|
|
||||||
|
DEFAULT_W, DEFAULT_H = 1280, 720
|
||||||
|
FONT_NAME = 'Noto Sans CJK JP'
|
||||||
|
BASE_FONT = 42
|
||||||
|
SCROLL_DURATION = 4.
|
||||||
|
STATIC_DURATION = 3.
|
||||||
|
MARGIN_X = 20
|
||||||
|
LANE_PADDING = 6
|
||||||
|
|
||||||
|
|
||||||
|
def ass_time (
|
||||||
|
t: float,
|
||||||
|
) -> str:
|
||||||
|
if t < 0:
|
||||||
|
t = 0
|
||||||
|
cs = int (round (t * 100))
|
||||||
|
s, cs = divmod (cs, 100)
|
||||||
|
m, s = divmod (s, 60)
|
||||||
|
h, m = divmod (m, 60)
|
||||||
|
return f"{h}:{m:02d}:{s:02d}.{cs:02d}"
|
||||||
|
|
||||||
|
def escape_ass (
|
||||||
|
text: str,
|
||||||
|
) -> str:
|
||||||
|
text = text.replace ('\n', ' ').replace ('\r', ' ')
|
||||||
|
text = text.replace ('{', r'\{').replace ('}', r'\}')
|
||||||
|
text = text.replace ('\\', r'\\')
|
||||||
|
return text.strip ()
|
||||||
|
|
||||||
|
def approx_text_width_px (
|
||||||
|
text: str,
|
||||||
|
font_size: float,
|
||||||
|
) -> float:
|
||||||
|
return max (40., .62 * font_size * len (text))
|
||||||
|
|
||||||
|
|
||||||
|
def build_ass (
|
||||||
|
comments: list[dict[str, Any]],
|
||||||
|
w: int,
|
||||||
|
h: int,
|
||||||
|
) -> str:
|
||||||
|
header = f"""[Script Info]
|
||||||
|
ScriptType: v4.00+
|
||||||
|
PlayResX: {w}
|
||||||
|
PlayResY: {h}
|
||||||
|
ScaledBorderAndShadow: yes
|
||||||
|
|
||||||
|
[V4+ Styles]
|
||||||
|
Format: Name, Fontname, Fontsize, PrimaryColour, SecondaryColour, OutlineColour, BackColour, Bold, Italic, Underline, StrikeOut, ScaleX, ScaleY, Spacing, Angle, BorderStyle, Outline, Shadow, Alignment, MarginL, MarginR, MarginV, Encoding
|
||||||
|
Style: Danmaku,{FONT_NAME},{BASE_FONT},&H00FFFFFF,&H00000000,&H00000000,&H64000000,0,0,0,0,100,100,0,0,1,2,1,7,{MARGIN_X},{MARGIN_X},10,1
|
||||||
|
|
||||||
|
[Events]
|
||||||
|
Format: Layer, Start, End, Style, Name, MarginL, MarginR, MarginV, Effect, Text
|
||||||
|
"""
|
||||||
|
events: list[str] = []
|
||||||
|
|
||||||
|
lane_h = int (BASE_FONT + LANE_PADDING)
|
||||||
|
lane_count = max (6, (h - 80) // lane_h)
|
||||||
|
lane_next_free = [0.] * lane_count
|
||||||
|
|
||||||
|
top_rows = max (1, (h // 5) // lane_h)
|
||||||
|
bottom_rows = top_rows
|
||||||
|
top_next_free = [0.] * top_rows
|
||||||
|
bottom_next_free = [0.] * bottom_rows
|
||||||
|
|
||||||
|
def pick_lane (
|
||||||
|
next_free: list[float],
|
||||||
|
start: float,
|
||||||
|
) -> int:
|
||||||
|
for i, nf in enumerate (next_free):
|
||||||
|
if nf <= start:
|
||||||
|
return i
|
||||||
|
return min (range (len (next_free)), key = lambda i: next_free[i])
|
||||||
|
|
||||||
|
for c in comments:
|
||||||
|
text = escape_ass (c['content'])
|
||||||
|
if not text:
|
||||||
|
continue
|
||||||
|
|
||||||
|
start = c['vpos_ms']
|
||||||
|
end = c['vpos_ms'] + SCROLL_DURATION
|
||||||
|
lane = pick_lane (lane_next_free, start)
|
||||||
|
y = 40 + lane * lane_h
|
||||||
|
|
||||||
|
tw = approx_text_width_px (text, 1.)
|
||||||
|
x1 = w + MARGIN_X
|
||||||
|
x2 = -tw - MARGIN_X
|
||||||
|
|
||||||
|
lane_next_free[lane] = start + (SCROLL_DURATION * .65)
|
||||||
|
|
||||||
|
override = rf"{{\fs1\c&H00FFFFFF\move({int(x1)},{int(y)},{int(x2)},{int(y)})}}"
|
||||||
|
events.append (
|
||||||
|
f"Dialogue: 0,{ass_time(start)},{ass_time(end)},Danmaku,,0,0,0,,{override}{text}")
|
||||||
|
|
||||||
|
return header + '\n'.join (events) + '\n'
|
||||||
@@ -1,3 +0,0 @@
|
|||||||
# 各変数に適切な値を設定し,ファイル名を youtube.py として保存すること
|
|
||||||
|
|
||||||
YOUTUBE_ID: str = 'XXXXXXXXXXX' # YouTube の配信 ID
|
|
||||||