CARVIEW |
Select Language
HTTP/2 200
date: Sat, 11 Oct 2025 14:13:35 GMT
content-type: text/html; charset=UTF-8
server: cloudflare
x-frame-options: DENY
x-content-type-options: nosniff
x-xss-protection: 1;mode=block
vary: accept-encoding
cf-cache-status: DYNAMIC
content-encoding: gzip
set-cookie: _csrf-frontend=0747ae5eb87809f73bb18d58da93a00131db5e9f52272127b537d35f8f466604a%3A2%3A%7Bi%3A0%3Bs%3A14%3A%22_csrf-frontend%22%3Bi%3A1%3Bs%3A32%3A%22Y_jKBUr9rucWxqvz0znN1hj731dfS5WD%22%3B%7D; HttpOnly; Path=/
cf-ray: 98cef57f6b76c16f-BLR
govor - kod - Pastebin.com
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class MainActivity : AppCompatActivity() {
- private lateinit var mic: ImageButton
- private lateinit var tvP: TextView
- private lateinit var tvO: TextView
- private var tts: TextToSpeech? = null
- //pokretanje aktivnosti prepoznavanja govora (Speech-to-Text) i vraćanje rezultata.
- private val speachLauncher = registerForActivityResult(ActivityResultContracts.StartActivityForResult()) //registracija
- {
- if (it.resultCode == RESULT_OK) { //
- val result = it.data?.getStringArrayListExtra(RecognizerIntent.EXTRA_RESULTS) //uzimanje govora RecognizerIntent (Androidova ugrađena aktivnost za prepoznavanje govora).
- val text = result?.getOrNull(0).orEmpty() //uzimanje prvog govora iz liste
- tvP.text = "Pitanje: $text" //prikaz govora na ekranu
- obradiTekst(text.lowercase(Locale.getDefault())) //poziv funkcije za obradu
- }
- }
- private fun obradiTekst(text: String) {
- val odgovor = when {
- text.contains("vrijeme") || text.contains("kiša")-> "Danas će u nekim krajevima padati kiša, ako kod Vas ne bude padala znači da niste u tim krajevima"
- text.contains("pobjeda") || text.contains("poraz") -> "Ako kaniš pobijediti, ne smiješ izgubiti"
- text.contains("teorija")|| text.contains("praksa")-> "U teoriji nema razlike između teorije i prakse. U praksi – ima."
- else -> "Nepoznato pitanje"
- }
- tvO.text="Odgovor: $odgovor"
- tts?.speak(odgovor, TextToSpeech.QUEUE_FLUSH, null, null)
- }
- override fun onCreate(savedInstanceState: Bundle?) {
- super.onCreate(savedInstanceState)
- enableEdgeToEdge()
- setContentView(R.layout.activity_main)
- ViewCompat.setOnApplyWindowInsetsListener(findViewById(R.id.main)) { v, insets ->
- val systemBars = insets.getInsets(WindowInsetsCompat.Type.systemBars())
- v.setPadding(systemBars.left, systemBars.top, systemBars.right, systemBars.bottom)
- insets
- }
- ActivityCompat.requestPermissions(this, arrayOf(android.Manifest.permission.RECORD_AUDIO), 1)
- mic = findViewById(R.id.btnPricaj)
- tvP = findViewById(R.id.tvPitanje)
- tvO = findViewById(R.id.tvOdgovor)
- mic.setOnClickListener { startSpeech() } //pokreni prepoznavanje govora
- tts = TextToSpeech(this) { status -> //inicijalizacija TextToSpeech
- if (status != TextToSpeech.ERROR) { //ako je inicijalizacija uspješna
- tts?.language = Locale.getDefault() //postavi jezik na trenutni
- }
- }
- }
- private fun startSpeech() {
- val intent = Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH).apply {
- putExtra(
- RecognizerIntent.EXTRA_LANGUAGE_MODEL, //model prepoznavanja govora
- RecognizerIntent.LANGUAGE_MODEL_FREE_FORM //tekstualni model
- )
- putExtra(
- RecognizerIntent.EXTRA_LANGUAGE,
- Locale.getDefault()
- ) //postavi jezik na trenutni
- putExtra(
- RecognizerIntent.EXTRA_PROMPT,
- "Govorite..."
- ) //tekst koji se prikazuje na ekranu
- }
- try {
- speachLauncher.launch(intent) //pokreni prepoznavanje govora
- } catch (e: Exception) {
- Toast.makeText(this, "Nije podržano", Toast.LENGTH_SHORT).show()
- }
- }
- override fun onDestroy() {
- tts?.stop() // prekida govor ako trenutno nešto čita
- tts?.shutdown() // potpuno oslobađa resurse TTS enginea
- super.onDestroy()
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
-
⭐ Instant BTC Profit Method ✅ NEVER SEEN BEFO...
JavaScript | 6 sec ago | 0.24 KB
-
⭐⭐⭐Exchange Exploit T 3⭐⭐
Java | 8 sec ago | 0.10 KB
-
⭐✅ MAKE $2000 INSTANTLY ✅ NEVER SEEN BEFORE ⭐...
JavaScript | 16 sec ago | 0.24 KB
-
⭐⭐⭐ChangeNOW Exploit⭐⭐
Java | 19 sec ago | 0.10 KB
-
⭐ Free Crypto Method ✅ NEVER SEEN BEFORE ⭐⭐⭐
JavaScript | 25 sec ago | 0.24 KB
-
⭐⭐⭐MAKE $9OO INSTANTLY D M⭐⭐
Java | 30 sec ago | 0.10 KB
-
✅⭐ Make huge profits on trading ✅ NEVER SEEN...
JavaScript | 34 sec ago | 0.24 KB
-
⭐⭐⭐Crypto Accounts⭐⭐
Java | 43 sec ago | 0.10 KB
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand