お疲れ様です<(_ _)>
昨晩は知人宅でBBQ!
もう夜は冷えますが・・最高w
そして息子のリズムが見事に崩壊
まぁ、そんなこともあるさ
22時半過ぎに帰宅
知人の子供(1歳と4歳)二人は途中で
おねむダウンだけど息子はいつまでも
ギンギン
リズムを整えても
そういう問題ではないんだなと
再認識だね
しかし赤ちゃん可愛い!
嫁いらんから赤ちゃん欲しい!
1歳3か月はもう掴まり立ち&喃語
すごいw
3歳8か月の息子とほぼ同等w
健常児はスーパーマンだね
もう10キロだって!
息子13キロw
帰りの代行は女性ドライバー
女性の代行は初!
育児相談のってくれましたw
そして清算時に向かった
代行カーのドライバーは若そうな
また女性、名コンビや
さて、AI同士で対話を永遠に繰り返すBotが
完成しました
GPTAPIの消費激しすぎて
初日は挫折しかけましたが・・
(数時間で10ドル消費)
モデルを4→3.5ターボに落として
少しいじると8時間程エンドレスしても
0.4ドル程度まで削減出来ました💦
モデルと、キャッシュの保持が特に
トークンを消費してたっぽいです
やり取りの記録を
いつまでも保持するから
トークンが膨れ上がるみたいな?
多分、そういうやつ
それも設定で調整できたので
まぁ3.5じゃ微妙ですが、AI同士の会話とは
こんなんです
個人的にかなり面白い取り組みw
pythonコードは以下
import openai
import requests
import urllib.parse
import os
import time
import re
# OpenAI APIキーの設定
openai.api_key = '自分のAPIキー'
def get_chatgpt_responses(prompt, current_role):
"""
ユーザーの入力に基づいて、AとBのリアクションを交互に生成します。
"""
# 現在のロールに応じて適切な指示を設定(プロンプト)
role_instructions = {
'A': "Aは〇〇としてリアクション。〇〇文字以内。",
'B': "Bは〇〇としてリアクション。〇〇文字以内。"
}
response = openai.ChatCompletion.create(
model="gpt-3.5-turbo",
messages=[
{"role": "system", "content": role_instructions[current_role]},
{"role": "user", "content": f"ユーザーの入力: '{prompt}'"}
]
)
# レスポンスの解析
response_text = response.choices[0].message['content'].strip()
print(f"API応答 ({current_role}): {response_text}") # デバッグ用のプリント
return response_text
def clean_text(text):
"""
テキストから'A:'や'B:'、および自己呼称を削除する
"""
# 'A:'や'B:'を削除
text = re.sub(r"^[AB]:\s*", "", text).strip()
# 自己呼称を削除 (例: '昭和おじさん:', '令和ギャル:')
text = re.sub(r"(〇〇|〇〇):", "", text).strip()
text = re.sub(r"( 〇〇|〇〇):", "", text).strip()
return text
def send_to_bouyomi(text, voice, speed, volume):
"""
棒読みちゃんにテキストを読み上げさせる
"""
voice_settings = f"voice={voice}&volume={volume}&speed={speed}"
encoded_text = urllib.parse.quote(text)
url = f"http://localhost:50080/talk?text={encoded_text}&{voice_settings}"
requests.get(url)
def write_to_text_file(filename, text):
"""
テキストをファイルに出力する (OBS用)
"""
with open(filename, 'w', encoding='utf-8') as f:
f.write(text)
if __name__ == "__main__":
# 初期のユーザー入力を受け取る
user_input = input("あなたのメッセージ: ")
initial_input = user_input # 初回のAはユーザーの入力をそのまま返すために保存
current_role = 'A' # 開始時の役割
while True:
if current_role == 'A':
# 初回のAはユーザーの入力をそのまま返す
response_text = initial_input if user_input == initial_input else get_chatgpt_responses(user_input, current_role)
# 'A:'を削除したテキストを棒読みちゃんに読み上げさせる
clean_response_text = clean_text(response_text)
print(f"棒読みちゃん用テキスト (A): {clean_response_text}")
send_to_bouyomi(clean_response_text, voice="1", speed=160, volume=40)
write_to_text_file('bouyomi_output.txt', clean_response_text)
current_role = 'B' # 次はBのリアクション
else:
# Bのリアクションを生成
response_text = get_chatgpt_responses(user_input, current_role)
# 'B:'を削除したテキストを棒読みちゃんに読み上げさせる
clean_response_text = clean_text(response_text)
print(f"リアクションテキスト (B): {clean_response_text}")
send_to_bouyomi(clean_response_text, voice="4", speed=140, volume=40)
write_to_text_file('reaction_output.txt', clean_response_text)
current_role = 'A' # 次はAのリアクション
# 次のループのために生成された応答を新しいユーザー入力として使用
user_input = response_text
# 10秒待機
time.sleep(10)
