Spaces:
Sleeping
Sleeping
Vlad Bastina commited on
Commit ·
baa9a50
1
Parent(s): 7cebc7b
secrets
Browse files- .gitignore +2 -2
- streamlit_app.py +13 -0
.gitignore
CHANGED
|
@@ -1,7 +1,7 @@
|
|
| 1 |
.env
|
| 2 |
-
|
| 3 |
gen-lang-client-0065207637-eaf8e92995b6.json
|
| 4 |
-
|
| 5 |
*.wav
|
| 6 |
prompt.txt
|
| 7 |
plot.png
|
|
|
|
| 1 |
.env
|
| 2 |
+
.streamlit/secrets.toml
|
| 3 |
gen-lang-client-0065207637-eaf8e92995b6.json
|
| 4 |
+
gcp_credentials.json
|
| 5 |
*.wav
|
| 6 |
prompt.txt
|
| 7 |
plot.png
|
streamlit_app.py
CHANGED
|
@@ -4,6 +4,19 @@ from streamlit_mic_recorder import mic_recorder
|
|
| 4 |
import wave
|
| 5 |
from sentiment_analysis import get_analysis
|
| 6 |
from PIL import Image
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 7 |
|
| 8 |
def save_audio(audio_data, filename):
|
| 9 |
"""Save the recorded audio in .wav format"""
|
|
|
|
| 4 |
import wave
|
| 5 |
from sentiment_analysis import get_analysis
|
| 6 |
from PIL import Image
|
| 7 |
+
import os
|
| 8 |
+
import json
|
| 9 |
+
|
| 10 |
+
os.environ['GOOGLE_API_KEY'] = st.secrets['GOOGLE_API_KEY']
|
| 11 |
+
google_credentials_json = json.dumps(dict(st.secrets["GOOGLE_APPLICATION_CREDENTIALS"]))
|
| 12 |
+
|
| 13 |
+
# Write the credentials to a temporary file
|
| 14 |
+
temp_file = "gcp_credentials.json"
|
| 15 |
+
with open(temp_file, "w") as f:
|
| 16 |
+
f.write(google_credentials_json)
|
| 17 |
+
|
| 18 |
+
# Set the environment variable to point to the temporary file
|
| 19 |
+
os.environ["GOOGLE_APPLICATION_CREDENTIALS"] = temp_file
|
| 20 |
|
| 21 |
def save_audio(audio_data, filename):
|
| 22 |
"""Save the recorded audio in .wav format"""
|