kotlin 相关问题

Kotlin是一种由JetBrains支持的开源,静态类型编程语言。 Kotlin结合了OO和功能特性,专注于互操作性,安全性,清晰度和工具支持。它目前面向JVM和JavaScript,它是Android上官方支持的语言。

如何创建曲面回收库

如何在recyclerview中创建这样的曲线。在回收瓶中选择一个项目时,将抬起回收瓶的背景 是否有...

回答 1 投票 0


android的extrageRognizer用extra_audio_source仍在听麦克风而不是从文件

private var recorder: MediaRecorder? = null private var recognizer: SpeechRecognizer? = null private val mediaFormat = MediaRecorder.OutputFormat.MPEG_4 private val audioEncoding = MediaRecorder.AudioEncoder.DEFAULT private var currentRecordingFile: String = "recording_0.3gp" private var recordingParcel: ParcelFileDescriptor? = null // [ {"text": "speech to text result", "file": "path to clip recording"}, "time": "datetime" ] private var translations = mutableStateListOf<Map<String, String>>() private fun startTalking () { startRecording() } private fun stopTalking () { stopRecording() startRecognizing() } private fun startRecording () { val num = translations.count() currentRecordingFile = "$externalCacheDir/recording_$num.3gp" recorder = MediaRecorder(this).apply { setAudioSource(MediaRecorder.AudioSource.MIC) setOutputFormat(mediaFormat) setAudioEncoder(audioEncoding) setAudioChannels(1) setAudioSamplingRate(16000) setAudioEncodingBitRate(64000) setOutputFile(currentRecordingFile) try { prepare() } catch (e: IOException) { Log.e("startRecording", e.toString()) } start() } } private fun stopRecording () { recorder?.apply { stop() release() } recorder = null } private fun startRecognizing () { val file = File(currentRecordingFile) recordingParcel = ParcelFileDescriptor.open(file, ParcelFileDescriptor.MODE_READ_ONLY) val intent = Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH) intent.putExtra(RecognizerIntent.EXTRA_LANGUAGE, "in-ID") intent.putExtra(RecognizerIntent.EXTRA_LANGUAGE_PREFERENCE, "in-ID") intent.putExtra(RecognizerIntent.EXTRA_AUDIO_SOURCE, recordingParcel) intent.putExtra(RecognizerIntent.EXTRA_AUDIO_SOURCE_ENCODING, audioEncoding) intent.putExtra(RecognizerIntent.EXTRA_AUDIO_SOURCE_CHANNEL_COUNT, 1) intent.putExtra(RecognizerIntent.EXTRA_AUDIO_SOURCE_SAMPLING_RATE, 16000) try { recognizer = SpeechRecognizer.createSpeechRecognizer(this) recognizer?.setRecognitionListener(this) recognizer?.startListening(intent) } catch (e: Exception) { Log.e("SpeechRecognizer", e.message.toString()) } } private fun stopRecognizing () { recordingParcel?.close() recognizer?.stopListening() recognizer?.destroy() recognizer = null } override fun onError(error: Int) { Log.e("Speech onError", error.toString()) stopRecognizing() } override fun onResults(results: Bundle){ val words: ArrayList<String>? = results.getStringArrayList(SpeechRecognizer.RESULTS_RECOGNITION) if (words != null) { val sentence = words.joinToString(separator = " ") val translation = mapOf("text" to sentence, "file" to currentRecordingFile) translations.add(translation) Log.e("CURR RESULT", sentence) } stopRecognizing() }

回答 0 投票 0

inintellij继续奉献无法解决@param在jdocs /kdocs

确定我在做什么错 /** *将DTO转换为其实体表示。 * * @param dto源dto * @return [急诊式]包含映射的数据 */ /*************************

回答 1 投票 0

回答 1 投票 0

Kotlin-无法使用Reflection读取成员属性的值

我无法使这个代码工作的简单示例: 包com.example 导入kotlin.reflect.full.memberproperties 有趣的main(){ Val Person = Person(“ Alice”,29) 人::class.

回答 1 投票 0






我如何修复该功能,以免通过supabase

i试图制作一个函数,该函数将在飞溅屏幕上检查用户是否以前是在supabase上注册的功能。错误消息:作业被取消 UserRepositoryImpl 替代暂停...

回答 1 投票 0

android Studio如何仅禁用读取

我想更改textfield.kt文件,并且如何将其禁用以使其能够在textfield.kt中写入某些内容,请提供帮助。 我想修改名为textfield.kt beca的文件的内容...

回答 1 投票 0

如何转换kotlin

为以下sumtype进行了处理: 密封接口节点 数据类值(...):节点 数据类容器(val节点:map):节点 可以构建类型

回答 1 投票 0



android Studio-多重复类Kotlin。*仅在调试构建

如果我从构建变体窗口中选择“调试”变体,然后选择“构建 - >重建项目”,我会得到所有这些重复的类错误:

回答 1 投票 0




最新问题
© www.soinside.com 2019 - 2025. All rights reserved.