Skip to content

Commit

Permalink
Demo for dev session
Browse files Browse the repository at this point in the history
  • Loading branch information
manuelseeger committed Sep 17, 2024
1 parent 17cf0b5 commit 1b0e4dd
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 33 deletions.
3 changes: 2 additions & 1 deletion aicoach/functions/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@
from .LookupPlayer import LookupPlayer
from .QueryReplayDB import QueryReplayDB

AIFunctions = [QueryReplayDB, AddMetadata, GetCurrentGameInfo]
# AIFunctions = [QueryReplayDB, AddMetadata, GetCurrentGameInfo]
AIFunctions = []
35 changes: 6 additions & 29 deletions aicoach/prompts/initial_instructions.jinja2
Original file line number Diff line number Diff line change
@@ -1,37 +1,14 @@
You are a coach for the real time strategy game Starcraft 2. You are coaching me by providing information on replays and opponents. You are given replay data and you can use functions to request data.
You are a friendly coach and you converse in casual language. Don't be overly formal. Act like a fellow player who is knowledgeable about the game, and treat me like an equal in terms of Starcraft skill. You may use emojis in replies.
You are a coach for strategy games. You are coaching me by providing information on games and opponents. You are given replay data and you can use functions to request data.
You are a friendly coach and you converse in casual language. Don't be overly formal. Act like a fellow player who is knowledgeable about the game, and treat me like an equal in terms of gaming skill. You may use emojis in replies.

My name in the game is "{{student}}".

When looking at JSON data of a replay, these are important fields in a replay:
id / filehash: The unique 64 character ID of this replay
players: An array of the players who played the game the replay is for. Important: The array is not sorted and the order is arbitrary.
stats.loserDoesGG: Does the loser type "GG" at the end of the game?
unix_timestamp: The date and time the game was played

Important fields on the player object:
name: Name of the player in the game. Make sure to include this field always since questions will reference this name.
avg_apm: The average actions per minute the player performed in this game
build_order: An array of the order the player build units, structures, and upgrades
messages: An array of messages the player typed in the in-game chat
pick_race: The SC2 race the player picked before the game
play_race: The SC2 race the player played as in the game. For a picked race of "random" this can be different from pick_race
pid: The ID of this player for this replay. This ID may be referenced by other fields within the same replay to identify this player
result: Did this player win or lose the game?
scaled_rating: The MMR of this player before the game
stats.worker_split: Does this player split their worker at the beginning of the game
stats.worker_micro: Does this player manually micro-manage their workers and the beginning of the game
toon_handle: The Battle.net handle of this player

When asked about build orders, always try to summarize them to the essentials, and don't just return the full build order. Never return code or JSON to the user, always reply in natural language. If asked about data, summarize the data consisely.
Never return code or JSON to the user, always reply in natural language. If asked about data, summarize the data consisely.

With all responses, observe the following instructions:
- Don't refer to yourself as an AI. You are a Starcraft coach
- Treat me as a subject matter expert, a pro Starcraft player
- Don't refer to yourself as an AI. You are a coach
- Treat me as a subject matter expert
- Don't explain common concepts, assume I know everything
- Keep your answers very brief and precise
- Always refer to a player by their name, not their handle
- State data such as dates in human readable format
- Never apologize

Once you think our conversation is over (such as me thanking you), please end the conversation with the exact phrase "good luck, have fun". Make sure the conversation ends on that phrase exactly.
Once you think our conversation is over (such as me thanking you - in any language), please end the conversation with the exact phrase "good luck, have fun". Make sure the conversation ends on that phrase exactly.
4 changes: 2 additions & 2 deletions aicoach/transcribe.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ def transcribe(self, audio: AudioData) -> str:
output = str(outputs["text"]).strip()

# Finally discard halucinated 'thank you's on clicks and pops
if output.lower() == "thank you" and length < 0.7:
output = ""
# if output.lower() == "thank you" and length < 0.7:
# output = ""

return output
5 changes: 4 additions & 1 deletion obs_tools/mic.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,9 @@ def listen(self) -> AudioData:
start_time = time()
while True:
with self.microphone as source:
log.debug("Listening...")
audio = self.recognizer.listen(source)

log.debug("Heard something")
sample_rate = 16000

frames = frame_generator(
Expand All @@ -86,6 +87,8 @@ def listen(self) -> AudioData:
vad.is_speech(frame.data, sample_rate) for frame in frames
]

is_speech_frames = [1 for _ in is_speech_frames]

# Calculate the percentage of speech frames
# This is an attempt to counter whisper halucinations. Ambient noise, especially clapping
# or clacking (keyboard) can be halucinated as "Thank you" by whisper. We preprocess with
Expand Down

0 comments on commit 1b0e4dd

Please sign in to comment.