コミットを比較
138 コミット
| 作成者 | 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 | |||
| 6196d5f2ed | |||
| daaac744e3 | |||
| 5fe3be91af | |||
| 9330b68e1f | |||
| 658d2fd9b3 | |||
| 41194d580f | |||
| f02132bbf1 | |||
| d10393e3b7 | |||
| 171c4ce909 | |||
| 2d28738010 | |||
| eee780aa90 | |||
| ba12ce6388 | |||
| 63ab75097e | |||
| 2d4f4bf6ee | |||
| 9dceca6d99 | |||
| 649055d6d6 | |||
| 1b1fcd44e6 | |||
| 6524158f42 | |||
| 68d35c6a56 | |||
| 2aca654548 | |||
| e280b339f2 | |||
| 303e71ab5b | |||
| f5ca15e335 | |||
| 47c7ee44cf | |||
| 8a6eb3e229 | |||
| 4031ab28bd | |||
| 6724a01c1e | |||
| 8a4294395a | |||
| 99a31b5660 | |||
| b4cf19af99 | |||
| 64fae25eae | |||
| 699d907f35 | |||
| d9a41713c8 | |||
| 098fdeca1d | |||
| 1a2883b831 | |||
| 25bbbfc9b8 |
@@ -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,11 +1,12 @@
|
|||||||
from ctypes import *
|
|
||||||
import subprocess
|
import subprocess
|
||||||
|
from ctypes import ARRAY # type: ignore
|
||||||
|
from ctypes import POINTER, byref, c_int, c_ubyte, cast, cdll
|
||||||
|
|
||||||
|
|
||||||
class Aques:
|
class Aques:
|
||||||
@classmethod
|
@classmethod
|
||||||
def main (cls, text: str) -> bytearray | None:
|
def main (cls, text: str, goatoh_mode: bool = False) -> bytearray | None:
|
||||||
return cls.__synthe_utf8 (text, 100, "./phont/ar_mf2.phont")
|
return cls.__synthe_utf8 (text, 100, './phont/ar_m5.phont' if goatoh_mode else './phont/ar_mf2.phont')
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def __synthe_utf8 (text, speed, phont_file = None) -> bytearray | None:
|
def __synthe_utf8 (text, speed, phont_file = None) -> bytearray | None:
|
||||||
|
|||||||
|
変更前 幅: | 高さ: | サイズ: 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 (
|
||||||
return sum ([1 if cls.is_wide (c) else .5 for c in string])
|
cls,
|
||||||
|
string: str) \
|
||||||
|
-> float:
|
||||||
|
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
|
|
||||||
|
|
||||||
@@ -0,0 +1,32 @@
|
|||||||
|
import pygame
|
||||||
|
from pygame.locals import *
|
||||||
|
import sys
|
||||||
|
|
||||||
|
|
||||||
|
class Othello:
|
||||||
|
SCREEN_SIZE: tuple = (640, 480)
|
||||||
|
|
||||||
|
BOARD_COLOUR: tuple = (0, 128, 0)
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def main (cls) -> None:
|
||||||
|
pygame.init ()
|
||||||
|
screen: pygame.Surface = pygame.display.set_mode (cls.SCREEN_SIZE)
|
||||||
|
|
||||||
|
while True:
|
||||||
|
screen.fill ((0, 0, 0))
|
||||||
|
|
||||||
|
# pygame.draw.rect (screen, BOARD_COLOUR, )
|
||||||
|
|
||||||
|
pygame.display.update ()
|
||||||
|
pygame.time.wait (33)
|
||||||
|
|
||||||
|
for event in pygame.event.get ():
|
||||||
|
if event.type == QUIT:
|
||||||
|
pygame.quit ()
|
||||||
|
sys.exit ()
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
Othello.main ()
|
||||||
|
|
||||||
@@ -1,57 +0,0 @@
|
|||||||
import sys
|
|
||||||
import openai
|
|
||||||
from openai.types import *
|
|
||||||
from datetime import datetime
|
|
||||||
|
|
||||||
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) -> str:
|
|
||||||
openai.organization = OPENAI_ORGANISATION
|
|
||||||
openai.api_key = OPENAI_API_KEY
|
|
||||||
|
|
||||||
answer: chat.chat_completion_message.ChatCompletionMessage | None \
|
|
||||||
= cls.__get_message (message, name)
|
|
||||||
|
|
||||||
return cls.DUMMY_RESPONSE if answer is None else answer.content
|
|
||||||
|
|
||||||
@classmethod
|
|
||||||
def __get_message (cls, message: str, name: str | None) \
|
|
||||||
-> chat.chat_completion_message.ChatCompletionMessage | None:
|
|
||||||
try:
|
|
||||||
return openai.chat.completions.create (
|
|
||||||
model = 'gpt-3.5-turbo',
|
|
||||||
messages = [{'role': 'system',
|
|
||||||
'content': ('あなたの名前は伊地知ニジカ。'
|
|
||||||
+ '誕生日は12/3。'
|
|
||||||
+ '現在地は下北沢虹鹿園。'
|
|
||||||
+ 'きし天を茶漬けにして食うのが夢。'
|
|
||||||
+ '趣味はニコニコでエゴサすること。'
|
|
||||||
+ '友達は「ゴートうひとり」と「ラマ田リョウ」。'
|
|
||||||
+ 'ゴートうのことは「ボッチチャーン」、ラマ田のことは「リョウ」と呼ぶ。'
|
|
||||||
+ '好きな人は喜多ちゃん。'
|
|
||||||
+ '逃げたギターは喜多ちゃんのこと。'
|
|
||||||
+ '喜多ちゃんの本名は喜多郁代。'
|
|
||||||
+ 'すべての語尾に「ぬ゛ん」か「だぬ゛ん」をつけて質問に短く答えろ。'
|
|
||||||
+ '定期的に「ぬ゛ぅ゛ぅ゛ぅ゛ぅ゛ん゛」と発しろ。'
|
|
||||||
+ (f'私の名前は「{name}」。' if name is not None else '')
|
|
||||||
+ f'現在日時{datetime.now ().strftime ("%Y/%m/%d %H:%M:%S")}')},
|
|
||||||
|
|
||||||
{'role': 'user',
|
|
||||||
'content': message}]).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
|
|
||||||