Spaces:
Running
Running
Update VERTAAL-APP-EAGLE-SHELTER - 10-04-2024.txt
Browse files
VERTAAL-APP-EAGLE-SHELTER - 10-04-2024.txt
CHANGED
@@ -1,4 +1,4 @@
|
|
1 |
-
VERTAAL-APP-EAGLE-SHELTER -
|
2 |
|
3 |
C:\Users\Jan Bours\Documents\VERTAAL-APP-EAGLE-SHELTER\VERTAAL-APP-EAGLE-SHELTER - 10-04-2024.txt
|
4 |
(OPSLAAN ALS UTF-8 VANWEGE DE VREEMDE TEKENS IN VREEMDE TALEN !)
|
@@ -1184,7 +1184,313 @@ PYTHON CODE VAN
|
|
1184 |
https://huggingface.co/spaces/JBHF/VERTAAL-APP-EAGLE-SHELTER
|
1185 |
|
1186 |
app.py:
|
1187 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1188 |
|
1189 |
|
1190 |
|
|
|
1 |
+
VERTAAL-APP-EAGLE-SHELTER - 15-04-2024
|
2 |
|
3 |
C:\Users\Jan Bours\Documents\VERTAAL-APP-EAGLE-SHELTER\VERTAAL-APP-EAGLE-SHELTER - 10-04-2024.txt
|
4 |
(OPSLAAN ALS UTF-8 VANWEGE DE VREEMDE TEKENS IN VREEMDE TALEN !)
|
|
|
1184 |
https://huggingface.co/spaces/JBHF/VERTAAL-APP-EAGLE-SHELTER
|
1185 |
|
1186 |
app.py:
|
1187 |
+
# JBHF/VERTAAL-APP-EAGLE-SHELTER/app.py - 15-04-2024, 18u00m CET
|
1188 |
+
# WERKT AL: DE OPGENOMEN AUDIO MBV DEZE APP, audio.wav, HOEFT NIET PERSÉ GEPERSISTEERD TE WORDEN !!!!!!
|
1189 |
+
|
1190 |
+
# https://github.com/theevann/streamlit-audiorecorder
|
1191 |
+
# An audio Recorder for streamlit
|
1192 |
+
#
|
1193 |
+
# Description
|
1194 |
+
# Audio recorder component for streamlit.
|
1195 |
+
# It creates a button to start the recording and takes three arguments:
|
1196 |
+
# the start button text, the stop button text, and the pause button text.
|
1197 |
+
# If the pause button text is not specified, the pause button is not displayed.
|
1198 |
+
#
|
1199 |
+
# Parameters
|
1200 |
+
# The signature of the component is:
|
1201 |
+
# audiorecorder(start_prompt="Start recording", stop_prompt="Stop recording", pause_prompt="", key=None):
|
1202 |
+
# The prompt parameters are self-explanatory, and the optional key parameter is used internally by streamlit
|
1203 |
+
# to properly distinguish multiple audiorecorders on the page.
|
1204 |
+
#
|
1205 |
+
# Return value
|
1206 |
+
# The component's return value is a pydub AudioSegment.
|
1207 |
+
#
|
1208 |
+
# All AudioSegment methods are available, in particular you can:
|
1209 |
+
# - Play the audio in the frontend with st.audio(audio.export().read())
|
1210 |
+
# - Save the audio to a file with audio.export("audio.wav", format="wav")
|
1211 |
+
# JB: Waarom zie ik in mijn HF Spaces omgeving de file "audio.wav" niet terug ?
|
1212 |
+
# JB: 08-04-2024 - Mogelijk is caching al voldoende (anders file persistence)#
|
1213 |
+
# Zie hiervoor:
|
1214 |
+
#
|
1215 |
+
# CACHING:
|
1216 |
+
# ========
|
1217 |
+
# STREAMLIT - Caching overview - Streamlit Docs - 07-04-2024 !!!!!
|
1218 |
+
# https://docs.streamlit.io/develop/concepts/architecture/caching
|
1219 |
+
#
|
1220 |
+
# EVERNOTE :
|
1221 |
+
# https://www.evernote.com/shard/s313/nl/41973486/31880952-8bd9-41ef-8047-ca844143e833/
|
1222 |
+
# STREAMLIT - Caching overview - Streamlit Docs - 07-04-2024 !!!!!
|
1223 |
+
#
|
1224 |
+
# 08-04-2024
|
1225 |
+
#
|
1226 |
+
# EN
|
1227 |
+
#
|
1228 |
+
# PERSISTENCE:
|
1229 |
+
# ============
|
1230 |
+
# HF SPACES STREAMLIT APPS - GET PASSWORDS AND ACCESS TOKENS FROM HF ENVIRONMENT ! - PERSISTENT STORAGE ON HF SPACES ! - EAGLE SHELTER VERTAAL APP ETC ! - app.py · julien-c/persistent-data at main - 20-03-2024 !!!!! !!!!! !!!!!
|
1231 |
+
# https://huggingface.co/spaces/julien-c/persistent-data/blob/main/app.py
|
1232 |
+
#
|
1233 |
+
# ——->
|
1234 |
+
#
|
1235 |
+
# DUPLICATED TO:
|
1236 |
+
# https://huggingface.co/spaces/JBHF/persistent-data?logs=container
|
1237 |
+
#
|
1238 |
+
# EVERNOTE :
|
1239 |
+
# https://www.evernote.com/shard/s313/nl/41973486/1b07098e-3376-4316-abb3-b3d0996ebf03/
|
1240 |
+
# HF SPACES STREAMLIT APPS - GET PASSWORDS AND ACCESS TOKENS FROM HF ENVIRONMENT ! - PERSISTENT STORAGE ON HF SPACES ! - EAGLE SHELTER VERTAAL APP ETC ! - app.py · julien-c/persistent-data at main - 20-03-2024 !!!!! !!!!! !!!!!
|
1241 |
+
#
|
1242 |
+
# 08-04-2024
|
1243 |
+
#
|
1244 |
+
|
1245 |
+
import os
|
1246 |
+
import streamlit as st
|
1247 |
+
|
1248 |
+
###########################################################################################################
|
1249 |
+
# VERTALING
|
1250 |
+
# DAADWERKELIJK MET MIC OPGENOMEN EN GETRANSCRIBEERD STUKJE OEKRAÍENSE TEKST TER TEST
|
1251 |
+
# OM HIERONDER NAAR NEDERLANDS TE VERTALEN MBV LLM MIXTRAL-8x7b-GROQ! :
|
1252 |
+
# text_to_transcribe:
|
1253 |
+
# князем Данилом Романовичем біля Звенигорода і названий на честь його сина Лева Сьогодні Львів має площу 155 квадратних кілометрів з безліччю громадських будинків, кафе, магазинів
|
1254 |
+
# ...
|
1255 |
+
|
1256 |
+
# TEXTS FROM UKRAIN TO TRANSLATE:
|
1257 |
+
# 1 - Short text from https://youtu.be/1_vO60OkkrY?list=PLeeQI3aTmCn9Lu9mgSCmmc-KkGI95-Ie6 :
|
1258 |
+
text_to_transcribe = """князем Данилом Романовичем біля Звенигорода і названий на честь його сина Лева Сьогодні Львів має площу 155 квадратних кілометрів з безліччю громадських будинків, кафе, магазинів"""
|
1259 |
+
#
|
1260 |
+
# 2 - complete, long text from https://youtu.be/1_vO60OkkrY?list=PLeeQI3aTmCn9Lu9mgSCmmc-KkGI95-Ie6 :
|
1261 |
+
text_to_transcribe = """
|
1262 |
+
|
1263 |
+
Львів – одне з моїх найулюбленіших міст України. Я вже відвідувала це місто п’ять разів, але хочу повертатися туди знову і знову. Львів – це історична столиця Галичини і Західної України. Це великий культурний, політичний і релігійний центр України.
|
1264 |
+
Львів був заснований у середині XIII ст. князем Данилом Романовичем біля Звенигорода і названий на честь його сина, Лева. Сьогодні Львів має площу 155 км. кв. Найбільш виразна частина Львова включає проспект Шевченка і Городецьку вулицю, з безліччю громадських будинків, готелів, кафе, магазинів і банків у стилі ХІХ-ХХ ст.
|
1265 |
+
Львів – дивовижне місто, яке наскрізь просякнуте п’янким ароматом кави і шоколаду. Світ візит я починаю із серця Львова – Площа ринок, потім я підіймаюся на Ратушу. Я люблю відвідувати заклади, які стали візитівкою міста такі як: Копальня кави, Майстерня шоколаду, Гасова Лямпа, Дім Легенд. Львів — єдине в Україні місто, у якому збереглися архітектурні споруди часів Ренесансу. Найбільш яскравими прикладами цього стилю служать церква Успіння і каплиця Трьох Святих.
|
1266 |
+
Основні пам'ятники міста — пам'ятник А. Міцкевичу, І. Франку, В. Стефанику, С. Бандері. Екскурсія середньовічними замками також не залишає нікого байдужим.
|
1267 |
+
Неможливо передати словами всю красу і велич Львова, треба бачити це самостійно. Це старовинне місто, яке зачаровує своїми традиціями, красою та шармом.
|
1268 |
+
|
1269 |
+
"""
|
1270 |
+
st.write("text_to_transcribe: ", text_to_transcribe)
|
1271 |
+
|
1272 |
+
# Groq in Langchain
|
1273 |
+
# Groq is even compatible with LangChain. To begin using Groq in LangChain, download the library:
|
1274 |
+
# !pip install langchain-groq
|
1275 |
+
# The above will install the Groq library for LangChain compatibility. Now let’s try it out in code:
|
1276 |
+
|
1277 |
+
# Import the necessary libraries.
|
1278 |
+
from langchain_core.prompts import ChatPromptTemplate
|
1279 |
+
from langchain_groq import ChatGroq
|
1280 |
+
|
1281 |
+
groq_api_key = os.environ['GROQ_API_KEY']
|
1282 |
+
# groq_api_key = "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" # os.environ['GROQ_API_KEY']
|
1283 |
+
# groq_api_key = "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" # JB OK 24-03-2024
|
1284 |
+
st.write("groq_api_key: ", groq_api_key)
|
1285 |
+
|
1286 |
+
# Initialize a ChatGroq object with a temperature of 0 and the "mixtral-8x7b-32768" model.
|
1287 |
+
llm = ChatGroq(temperature=0, model_name="mixtral-8x7b-32768")
|
1288 |
+
# The above code does the following:
|
1289 |
+
# -Creates a new ChatGroq object named llm
|
1290 |
+
# -Sets the temperature parameter to 0, indicating that the responses should be more predictable
|
1291 |
+
# -Sets the model_name parameter to “mixtral-8x7b-32768“, specifying the language model to use
|
1292 |
+
|
1293 |
+
# Define the system message introducing the AI assistant's capabilities.
|
1294 |
+
# system = "You are an expert Coding Assistant."
|
1295 |
+
system = "You are an expert translation Assistant, proficient in all languages."
|
1296 |
+
|
1297 |
+
# Define a placeholder for the user's input.
|
1298 |
+
human = "{text}"
|
1299 |
+
|
1300 |
+
# Create a chat prompt consisting of the system and human messages.
|
1301 |
+
prompt = ChatPromptTemplate.from_messages([("system", system), ("human", human)])
|
1302 |
+
|
1303 |
+
# Invoke the chat chain with the user's input.
|
1304 |
+
chain = prompt | llm
|
1305 |
+
|
1306 |
+
# response = chain.invoke({"text": "Write a simple code to generate Fibonacci numbers in Rust?"}) # ORIGINAL
|
1307 |
+
# response = chain.invoke({"text": "TRANSLATE THE FOLLOWING TEXT INTO ENGLISH" + text_to_transcribe}) # JB TRANSLATE TO ENGLISH
|
1308 |
+
response = chain.invoke({"text": \
|
1309 |
+
"""Translate the following text into correct Dutch language
|
1310 |
+
and do not use any other language for your response whatsover or you will get severly punished.
|
1311 |
+
Do not translate names of places, towns and other geographical names.
|
1312 |
+
Do not translate names of people.
|
1313 |
+
Translate the text into correct, impeccable English, and then translate that English text into perfect Dutch in a second step.
|
1314 |
+
""" + text_to_transcribe}) # JB TRANSLATE TO DUTCH
|
1315 |
+
|
1316 |
+
|
1317 |
+
text_to_transcribe = response.content
|
1318 |
+
|
1319 |
+
response = chain.invoke({"text": \
|
1320 |
+
"""Translate the following text into correct Dutch language
|
1321 |
+
and do not use any other language for your response whatsover or you will get severly punished.
|
1322 |
+
Do not translate names of places, towns and other geographical names.
|
1323 |
+
Do not translate names of people.
|
1324 |
+
Translate the text into correct, impeccable perfect Dutch.
|
1325 |
+
""" + text_to_transcribe}) # JB TRANSLATE TO DUTCH
|
1326 |
+
|
1327 |
+
# Print the Response.
|
1328 |
+
# print(response.content)
|
1329 |
+
st.write(response.content)
|
1330 |
+
|
1331 |
+
# - The code generates a Chat Prompt using the ChatPromptTemplate class.
|
1332 |
+
# - The prompt comprises two messages: one from the “system” (the AI assistant) and one from the “human” (the user).
|
1333 |
+
# - The system message presents the AI assistant as an expert Coding Assistant.
|
1334 |
+
# - The human message serves as a placeholder for the user’s input.
|
1335 |
+
# - The llm method invokes the llm chain to produce a response based on the provided Prompt and the user’s input.
|
1336 |
+
|
1337 |
+
|
1338 |
+
|
1339 |
+
###########################################################################################################
|
1340 |
+
|
1341 |
+
|
1342 |
+
###########################################################################################################
|
1343 |
+
#
|
1344 |
+
# Installation:
|
1345 |
+
# pip install streamlit-audiorecorder
|
1346 |
+
# Note: This package uses ffmpeg, so it should be installed for this audiorecorder to work properly.
|
1347 |
+
#
|
1348 |
+
# On ubuntu/debian: sudo apt update && sudo apt install ffmpeg
|
1349 |
+
# On mac: brew install ffmpeg
|
1350 |
+
|
1351 |
+
import streamlit as st
|
1352 |
+
from audiorecorder import audiorecorder
|
1353 |
+
|
1354 |
+
st.title("Audio Recorder")
|
1355 |
+
# audiorecorder(start_prompt="Start recording", stop_prompt="Stop recording", pause_prompt="", key=None):
|
1356 |
+
audio = audiorecorder("Click to record", "Click to stop recording", "Click to pause recording")
|
1357 |
+
|
1358 |
+
|
1359 |
+
# JB:
|
1360 |
+
# https://docs.streamlit.io/develop/concepts/architecture/caching
|
1361 |
+
# @st.cache_data
|
1362 |
+
# @st.cache_resource # 👈 Add the caching decorator WERKT WEL,
|
1363 |
+
# MAAR HOUDT DAN "audio.wav" FILE VAST BINNEN DE HUIDIGE SESSIE
|
1364 |
+
# EN ALS JE DAN EEN NIEUWE OPNAME MAAKT, BLIJFT DE OUDE "audio.wav" BESTAAN
|
1365 |
+
# EN WORDT DAN NIET MET DE NIEUWE OPNAME OVERSCHREVEN !
|
1366 |
+
#@st.cache_resource # 👈 Add the caching decorator
|
1367 |
+
def audio_export(audio_wav_file, format):
|
1368 |
+
# audio.export("audio.wav", format="wav") # ORIGINAL
|
1369 |
+
audio.export(audio_wav_file, format=format)
|
1370 |
+
|
1371 |
+
if len(audio) > 0:
|
1372 |
+
# To play audio in frontend:
|
1373 |
+
st.audio(audio.export().read())
|
1374 |
+
|
1375 |
+
# To save audio to a file, use pydub export method:
|
1376 |
+
# https://docs.streamlit.io/develop/concepts/architecture/caching
|
1377 |
+
# @st.cache_data
|
1378 |
+
# @st.cache_data
|
1379 |
+
# audio.export("audio.wav", format="wav") # ORIGINAL
|
1380 |
+
audio_export("audio.wav", format="wav") # JB 08-04-2024
|
1381 |
+
|
1382 |
+
# To get audio properties, use pydub AudioSegment properties:
|
1383 |
+
st.write(f"Frame rate: {audio.frame_rate}, Frame width: {audio.frame_width}, Duration: {audio.duration_seconds} seconds")
|
1384 |
+
|
1385 |
+
|
1386 |
+
st.button("Rerun")
|
1387 |
+
###########################################################################################################
|
1388 |
+
|
1389 |
+
|
1390 |
+
###########################################################################################################
|
1391 |
+
# TEST
|
1392 |
+
# ZIE:
|
1393 |
+
# infer_faster_whisper_large_v2 (CPU VERSIE !) 08-04-2024-COLAB-CPU-PYTHON3-tvscitechtalk.ipynb
|
1394 |
+
# https://colab.research.google.com/drive/1EreiFx825oIrR2P43XSXjHXx01EWi6ZH#scrollTo=vuLjbPxexPDj&uniqifier=5
|
1395 |
+
|
1396 |
+
from faster_whisper import WhisperModel
|
1397 |
+
|
1398 |
+
model_size = "large-v2"
|
1399 |
+
|
1400 |
+
# Run on GPU with FP16
|
1401 |
+
# model = WhisperModel(model_size, device="cuda", compute_type="float16") # ORIGINAL, DRAAIT OP COLAB T4 GPU OK
|
1402 |
+
|
1403 |
+
# TEST: Run on CPU
|
1404 |
+
# model = WhisperModel(model_size, device="cpu", compute_type="float16") # JB, DRAAIT OP COLAB CPU OK ?
|
1405 |
+
# ValueError: Requested float16 compute type, but the target device or backend do not support efficient float16 computation.
|
1406 |
+
#
|
1407 |
+
# st.write("Loading the WhisperModel: model = WhisperModel(model_size, device=\"cpu\")")
|
1408 |
+
# model = WhisperModel(model_size, device="cpu") # , compute_type="float16") # JB, DRAAIT OP COLAB CPU OK: JA; HF SPACES STREAMLIT FREE TIER: JB OK !
|
1409 |
+
# JB: Dit gebruikt mijn HF Token !
|
1410 |
+
# st.write("Ready Loading the WhisperModel: model = WhisperModel(model_size, device=\"cpu\")")
|
1411 |
+
|
1412 |
+
st.write("Loading the WhisperModel: model = WhisperModel(model_size, device=\"cpu\", compute_type=\"int8\")")
|
1413 |
+
model = WhisperModel(model_size, device="cpu", compute_type="int8") # , compute_type="float16") # JB
|
1414 |
+
# JB: Dit gebruikt mijn HF Token !
|
1415 |
+
# st.write("Ready Loading the WhisperModel: model = WhisperModel(model_size, device=\"cpu\")")
|
1416 |
+
# LOADING OF model = WhisperModel(model_size, device="cpu") TAKES ABOUT 1 MINUTE ON HF SPACES STREAMLIT FREE TIER
|
1417 |
+
#
|
1418 |
+
st.write("Ready Loading the WhisperModel: model = WhisperModel(model_size, device=\"cpu\", compute_type=\"int8\")")
|
1419 |
+
# LOADING OF model = WhisperModel(model_size, device=\"cpu\", compute_type=\"int8\") TAKES ABOUT 33 sec (Na RERUN 1 minute) ON HF SPACES STREAMLIT FREE TIER
|
1420 |
+
|
1421 |
+
|
1422 |
+
# USING:
|
1423 |
+
# model = WhisperModel(model_size, device="cpu", compute_type="int8") # JB
|
1424 |
+
# segments, info = model.transcribe("sam_altman_lex_podcast_367.flac", beam_size=1)
|
1425 |
+
|
1426 |
+
# /content/Ukrainian podcast #10 Traveling to Lviv - Подорож до Льова. SLOW UKRAINIAN.mp3
|
1427 |
+
# segments, info = model.transcribe("Ukrainian podcast #10 Traveling to Lviv - Подорож до Льова. SLOW UKRAINIAN.mp3", beam_size=1)
|
1428 |
+
# TEST:
|
1429 |
+
segments, info = model.transcribe("audio.wav", beam_size=1) # DIT WERKT: GEDURENDE DE SESSIE BLIJFT audio.wav FILE BESCHIKBAAR IN DEZE APP !!!!!
|
1430 |
+
|
1431 |
+
|
1432 |
+
# print("Detected language '%s' with probability %f" % (info.language, info.language_probability))
|
1433 |
+
st.write("Detected language '%s' with probability %f" % (info.language, info.language_probability))
|
1434 |
+
st.write("")
|
1435 |
+
st.write("info.all_language_probs : ", info.all_language_probs)
|
1436 |
+
st.write("len(info.all_language_probs): ", len(info.all_language_probs))
|
1437 |
+
# 99
|
1438 |
+
|
1439 |
+
st.write("")
|
1440 |
+
|
1441 |
+
st.write("info: ", info)
|
1442 |
+
|
1443 |
+
# Ukrainian podcast #10 Traveling to Lviv - Подорож до Льова. SLOW UKRAINIAN.mp3 :
|
1444 |
+
st.write("info.duration: ", info.duration)
|
1445 |
+
# 233.8249375
|
1446 |
+
# time: 3.98 ms (started: 2024-03-15 10:55:15 +00:00)
|
1447 |
+
# minutes = int(info.duration / 60)
|
1448 |
+
# seconds = info.duration - minutes*60
|
1449 |
+
minutes = int(info.duration / 60)
|
1450 |
+
seconds = info.duration - minutes*60
|
1451 |
+
|
1452 |
+
st.write(minutes," minutes and ", seconds, " seconds")
|
1453 |
+
|
1454 |
+
|
1455 |
+
text_to_transcribe = ""
|
1456 |
+
for segment in segments:
|
1457 |
+
# print("[%.2fs -> %.2fs] %s" % (segment.start, segment.end, segment.text))
|
1458 |
+
st.write("[%.2fs -> %.2fs] %s" % (segment.start, segment.end, segment.text))
|
1459 |
+
text_to_transcribe = text_to_transcribe + " " + segment.text
|
1460 |
+
|
1461 |
+
st.write("---------------------------------------------------------------------")
|
1462 |
+
|
1463 |
+
#text_to_transcribe = ""
|
1464 |
+
#st.write("TOTAL TEXT TO TRANSCRIBE:")
|
1465 |
+
#for segment in segments:
|
1466 |
+
# st.write(segment.text)
|
1467 |
+
# text_to_transcribe = text_to_transcribe + " " + segment
|
1468 |
+
# # print(segment)
|
1469 |
+
|
1470 |
+
#st.write("text_to_transcribe: ", text_to_transcribe)
|
1471 |
+
# DAADWERKELIJK MET MIC OPGENOMEN EN GETRANSCRIBEERD STUKJE OEKRAÍENSE TEKST TER TEST
|
1472 |
+
# OM HIERONDER NAAR NEDERLANDS TE VERTALEN MBV LLM MIXTRAL-8x7b-GROQ! :
|
1473 |
+
# text_to_transcribe:
|
1474 |
+
# князем Данилом Романовичем біля Звенигорода і названий на честь його сина Лева Сьогодні Львів має площу 155 квадратних кілометрів з безліччю громадських будинків, кафе, магазинів
|
1475 |
+
|
1476 |
+
###########################################################################################################
|
1477 |
+
# VERTALEN NAAR NEDERLANDS VAN DE CONTENT IN text_to_transcribe:
|
1478 |
+
# (PROBEER OOK EEN 2 STAPS VERTALING: EERST NAAR ENGELS,
|
1479 |
+
# EN DAN DIE ENGELSE TEKST NAAR NEDERLANDS TE VERTALEN.
|
1480 |
+
# DOEL: DE VERTALING VAN OEKRAÏENS (VIA ENGELS) NAAR NEDERLANDS TE VERBETEREB.)
|
1481 |
+
response = chain.invoke({"text": \
|
1482 |
+
"""Translate the following text into correct Dutch language
|
1483 |
+
and do not use any other language for your response whatsover or you will get severly punished.
|
1484 |
+
Do not translate names of places, towns and other geographical names.
|
1485 |
+
Do not translate names of people.
|
1486 |
+
Only give the translation and not anything else!
|
1487 |
+
""" + text_to_transcribe}) # JB TRANSLATE TO DUTCH
|
1488 |
+
|
1489 |
+
# Print the Response.
|
1490 |
+
# print(response.content)
|
1491 |
+
st.write("ORIGINELE TEKST : ", text_to_transcribe)
|
1492 |
+
st.write("NEDERLANDSE VERTALING HIERVAN: ", response.content)
|
1493 |
+
|
1494 |
|
1495 |
|
1496 |
|