The suggestions already made about singing something and playing it back are an essential element of what I share with my students.
Most of us hear shapes in our head, but don't always know what notes go with them.
One exercise is to sing a chorus along with a great record and record it. Yes, that means singing a solo on top of the melody or another soloist! Try to sing rhythmically with a contour of pitch emulating what any of your favorite soists might play. Don't worry about pitch so much at first. Transcribe the rhythm and contour you sang. Correct the pitches as needed, but don't forget to use chromaticism!! If it is too diatonic, it won't sound right. The more one does this, the closer the right notes will come out in real time. It is tedious to do at first, but will get better over time.
Also very important is to use the melody. It often will contain great notes that can be used as target notes in your own solo.