๐ค CLARISSA Voice Input Showcaseยถ
Talk to Your Reservoir Simulation
This notebook demonstrates CLARISSA's voice interface for controlling reservoir simulations through natural language commands.
๐ Workflowยถ
| Step | Where | What |
|---|---|---|
| 1๏ธโฃ | Web Demo | Record your voice command |
| 2๏ธโฃ | This Notebook | Upload + Transcribe + Process |
๐ Step 1: Record Your Voiceยถ
๐ Open Voice Demo (opens in new tab)
- Click "Start Recording"
- Speak your command (e.g., "show permeability distribution")
- Click "Stop"
- Click "Download WAV"
- Come back here and upload the file
Inย [ย ]:
Copied!
# Setup (run once)
!pip install -q openai
import os
from IPython.display import display, HTML, Audio
from google.colab import files
print("โ
Ready! Upload your audio file below.")
# Setup (run once)
!pip install -q openai
import os
from IPython.display import display, HTML, Audio
from google.colab import files
print("โ
Ready! Upload your audio file below.")
๐ค Step 2: Upload Your Recordingยถ
Inย [ย ]:
Copied!
# Upload your recorded audio file
print("๐ Select your audio file (WAV, WebM, MP3, etc.)")
print()
uploaded = files.upload()
if uploaded:
filename = list(uploaded.keys())[0]
audio_bytes = uploaded[filename]
print()
print(f"โ
Uploaded: {filename} ({len(audio_bytes):,} bytes)")
print()
print("๐ Playback:")
display(Audio(audio_bytes, autoplay=False))
else:
print("โ No file uploaded")
audio_bytes = None
# Upload your recorded audio file
print("๐ Select your audio file (WAV, WebM, MP3, etc.)")
print()
uploaded = files.upload()
if uploaded:
filename = list(uploaded.keys())[0]
audio_bytes = uploaded[filename]
print()
print(f"โ
Uploaded: {filename} ({len(audio_bytes):,} bytes)")
print()
print("๐ Playback:")
display(Audio(audio_bytes, autoplay=False))
else:
print("โ No file uploaded")
audio_bytes = None
Inย [ย ]:
Copied!
# Transcribe the uploaded audio
import tempfile
from getpass import getpass
# Get API key
if not os.environ.get('OPENAI_API_KEY'):
os.environ['OPENAI_API_KEY'] = getpass("OpenAI API Key: ")
if audio_bytes:
from openai import OpenAI
client = OpenAI()
# Save to temp file
ext = filename.split('.')[-1] if '.' in filename else 'wav'
with tempfile.NamedTemporaryFile(suffix=f'.{ext}', delete=False) as f:
f.write(audio_bytes)
temp_path = f.name
print("๐ Transcribing...")
with open(temp_path, 'rb') as audio_file:
transcript = client.audio.transcriptions.create(
model="whisper-1",
file=audio_file,
language="en",
prompt="Reservoir simulation commands: permeability, porosity, pressure, saturation, water cut, oil rate, injection, production, layers, wells, grid"
)
os.unlink(temp_path)
print()
print("โ" * 50)
print("๐ TRANSCRIPT")
print("โ" * 50)
print()
print(f' "{transcript.text}"')
print()
# Store for next cell
command_text = transcript.text
else:
print("โ No audio to transcribe. Run the upload cell first.")
command_text = None
# Transcribe the uploaded audio
import tempfile
from getpass import getpass
# Get API key
if not os.environ.get('OPENAI_API_KEY'):
os.environ['OPENAI_API_KEY'] = getpass("OpenAI API Key: ")
if audio_bytes:
from openai import OpenAI
client = OpenAI()
# Save to temp file
ext = filename.split('.')[-1] if '.' in filename else 'wav'
with tempfile.NamedTemporaryFile(suffix=f'.{ext}', delete=False) as f:
f.write(audio_bytes)
temp_path = f.name
print("๐ Transcribing...")
with open(temp_path, 'rb') as audio_file:
transcript = client.audio.transcriptions.create(
model="whisper-1",
file=audio_file,
language="en",
prompt="Reservoir simulation commands: permeability, porosity, pressure, saturation, water cut, oil rate, injection, production, layers, wells, grid"
)
os.unlink(temp_path)
print()
print("โ" * 50)
print("๐ TRANSCRIPT")
print("โ" * 50)
print()
print(f' "{transcript.text}"')
print()
# Store for next cell
command_text = transcript.text
else:
print("โ No audio to transcribe. Run the upload cell first.")
command_text = None
Inย [ย ]:
Copied!
# Parse the intent from the transcript
if command_text:
# Simple keyword-based intent detection
text_lower = command_text.lower()
# Define intents
intents = []
# Property queries
if any(w in text_lower for w in ['permeability', 'perm']):
intents.append(('SHOW_PROPERTY', 'permeability'))
if any(w in text_lower for w in ['porosity', 'poro']):
intents.append(('SHOW_PROPERTY', 'porosity'))
if 'pressure' in text_lower:
intents.append(('SHOW_PROPERTY', 'pressure'))
if any(w in text_lower for w in ['saturation', 'sat']):
intents.append(('SHOW_PROPERTY', 'saturation'))
if any(w in text_lower for w in ['water cut', 'watercut']):
intents.append(('SHOW_METRIC', 'water_cut'))
if any(w in text_lower for w in ['oil rate', 'production rate']):
intents.append(('SHOW_METRIC', 'oil_rate'))
# Actions
if any(w in text_lower for w in ['run', 'simulate', 'execute']):
intents.append(('RUN_SIMULATION', None))
if any(w in text_lower for w in ['stop', 'cancel', 'abort']):
intents.append(('STOP_SIMULATION', None))
# Questions
if any(w in text_lower for w in ['what is', 'what are', 'how much', 'how many']):
intents.append(('QUERY', 'general'))
print("โ" * 50)
print("๐ง INTENT ANALYSIS")
print("โ" * 50)
print()
print(f"Input: \"{command_text}\"")
print()
if intents:
print("Detected intents:")
for intent_type, intent_value in intents:
if intent_value:
print(f" โข {intent_type}: {intent_value}")
else:
print(f" โข {intent_type}")
else:
print(" โ ๏ธ No specific intent detected")
print(" โ Would pass to LLM for interpretation")
print()
print("โ" * 50)
print("๐ก In production, this would trigger CLARISSA actions")
else:
print("โ No transcript available. Run the transcription cell first.")
# Parse the intent from the transcript
if command_text:
# Simple keyword-based intent detection
text_lower = command_text.lower()
# Define intents
intents = []
# Property queries
if any(w in text_lower for w in ['permeability', 'perm']):
intents.append(('SHOW_PROPERTY', 'permeability'))
if any(w in text_lower for w in ['porosity', 'poro']):
intents.append(('SHOW_PROPERTY', 'porosity'))
if 'pressure' in text_lower:
intents.append(('SHOW_PROPERTY', 'pressure'))
if any(w in text_lower for w in ['saturation', 'sat']):
intents.append(('SHOW_PROPERTY', 'saturation'))
if any(w in text_lower for w in ['water cut', 'watercut']):
intents.append(('SHOW_METRIC', 'water_cut'))
if any(w in text_lower for w in ['oil rate', 'production rate']):
intents.append(('SHOW_METRIC', 'oil_rate'))
# Actions
if any(w in text_lower for w in ['run', 'simulate', 'execute']):
intents.append(('RUN_SIMULATION', None))
if any(w in text_lower for w in ['stop', 'cancel', 'abort']):
intents.append(('STOP_SIMULATION', None))
# Questions
if any(w in text_lower for w in ['what is', 'what are', 'how much', 'how many']):
intents.append(('QUERY', 'general'))
print("โ" * 50)
print("๐ง INTENT ANALYSIS")
print("โ" * 50)
print()
print(f"Input: \"{command_text}\"")
print()
if intents:
print("Detected intents:")
for intent_type, intent_value in intents:
if intent_value:
print(f" โข {intent_type}: {intent_value}")
else:
print(f" โข {intent_type}")
else:
print(" โ ๏ธ No specific intent detected")
print(" โ Would pass to LLM for interpretation")
print()
print("โ" * 50)
print("๐ก In production, this would trigger CLARISSA actions")
else:
print("โ No transcript available. Run the transcription cell first.")
๐ Resourcesยถ
| Resource | Link |
|---|---|
| ๐ค Voice Demo | irena-40cc50.gitlab.io/demos/voice-demo.html |
| ๐ฌ Recording Suite | irena-40cc50.gitlab.io/demos/demo-recording-suite.html |
| ๐ CLARISSA Docs | irena-40cc50.gitlab.io |
| ๐ป Source Code | GitLab Repository |
๐ Example Commands to Tryยถ
- "Show me the permeability distribution"
- "What is the current water cut?"
- "Display pressure in layer 3"
- "Run the simulation"
- "What are the oil production rates?"