Skip to content

Commit

Permalink
Merge pull request #46 from bunju20/develop
Browse files Browse the repository at this point in the history
fix: 음소 인식 페이지 오류 수정
  • Loading branch information
seochan99 authored Feb 21, 2024
2 parents a9c84e0 + 0850c38 commit 72828da
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 10 deletions.
17 changes: 12 additions & 5 deletions lib/viewModels/record/record_viewmodel.dart
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,17 @@ class RecordViewModel extends GetxController {
}

Future<void> sendTextAndAudio(String content, int type) async {

isRecording.value ? await _stopRecording() : await _startRecording();
update();
if(isRecording.value == true) {
return;
}
print("들어오긴 함?");
String url =
'${dotenv.env['API_URL']!}/study/${type == 0 ? 'syllable' : (type == 1 ? 'word' : 'sentence')}';


print(audioFilePath.value);
if (audioFilePath.value.isEmpty) {
return;
Expand All @@ -85,14 +93,13 @@ class RecordViewModel extends GetxController {
final jsonResponse = json.decode(respStr);
//
this.response.value = jsonResponse;
} else {}
print(jsonResponse);
} else {
print('Failed to upload');
}
} catch (e) {}
}

void toggleRecording() async {
isRecording.value ? await _stopRecording() : await _startRecording();
update();
}

@override
void onClose() {
Expand Down
7 changes: 2 additions & 5 deletions lib/views/word/widget/word_sentence_widget.dart
Original file line number Diff line number Diff line change
Expand Up @@ -37,18 +37,15 @@ class WordSentenceWidget extends StatelessWidget {
borderRadius: BorderRadius.circular(40),
onTap: () async {
if (model.isRecording.value) {
// 녹음 토글 버튼
print('녹음 종료');
model.toggleRecording();

await model.sendTextAndAudio(
wordDataList[wordViewModel.currentIndex.value]
.wordCard
.word,
type);

// Handle the response here, e.g., show it in a dialog
Get.dialog(
// height
AlertDialog(
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(20),
Expand Down Expand Up @@ -182,7 +179,7 @@ class WordSentenceWidget extends StatelessWidget {
} else {
// Start recording
print('녹음 시작');
model.toggleRecording();
model.sendTextAndAudio('content', 0);
}
},
child: Padding(
Expand Down

0 comments on commit 72828da

Please sign in to comment.